Thread: Save As Dialog
View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Larry Dodd Larry Dodd is offline
external usenet poster
 
Posts: 3
Default Save As Dialog

I am trying to put some code in the BeforeSave event so that when the user
tries to save the workbook they will be prompted with the Save As dialog
with a different file name so they do not save over the original file.

I am using the SafeFileAs function and the Save As dialog does appear but
the initial directory is set to My Documents and I would like it to be set
to something else. Below is the code that I am using. Can anyone tell me how
I can accomplish this?

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Dim DialogResult As String
Dim UserFileName As String
Dim sAppPath As String

Application.EnableEvents = False
sAppPath = ActiveWorkbook.Path & "\Bone Match 5.0 Template
Directory\Bone Match 5.0
History\BoneMatch.xls"

DialogResult = Application.GetSaveAsFilename(InitialFileName:=sAp pPath,
FileFilter:="Microsoft
Office Excel Workbook (*.xls), *.xls")

If DialogResult = "False" Then
Application.EnableEvents = True
Cancel = True
Exit Sub
End If

UserFileName = CStr(DialogResult)
Workbook.SaveAs (UserFileName)

Application.EnableEvents = True

End Sub