PDA

View Full Version : Problems with SaveAs



timd
2005-02-02, 06:20 PM
I am using the following code to allow a user to save a drawing. The problem that I am having is that if the file already exists it just overwrites it and doesn't bring up the "Are you sure you want to overwrite" warning. I am assuming that I am missing a line of code that turns display alerts on, but I can't find the code that I need to do this.

Does anyone else know?

Thanks

Private Sub newfile_Click()
On Error GoTo ErrHandler
' empty the filename in the dialog box
CommonDialog1.FileName = ""
CommonDialog1.MaxFileSize = 32000
CommonDialog1.Filter = "Drawing Files (*.dwg)|*.dwg"
CommonDialog1.DefaultExt = "*.dwg"
CommonDialog1.FilterIndex = 1
CommonDialog1.DialogTitle = "Select New RED file location and name:"
' Set Cancel to True.
CommonDialog1.CancelError = False
CommonDialog1.Showsave
infilename.Text = CommonDialog1.FileName
Dim RedDwg As AcadDocument
Set RedDwg = Application.Documents.Add("acad.dwt")
RedDwg.SaveAs (infilename)
RedName = RedDwg.Path & "" & RedDwg.Name
RedDwg.Close
newRed = 1
If saveit = 0 Then
Unload Me
End If
Exit Sub
ErrHandler:
' User pressed Cancel button.
Exit Sub
End Sub