Thread: Save As Dialog
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Robin Hammond[_2_] Robin Hammond[_2_] is offline
external usenet poster
 
Posts: 575
Default Save As Dialog

Larry,

just use a combination of ChDrive and ChDir as follows:

Sub SaveInDir()
ChDrive "c:"
ChDir "c:\Temp"
strFile = Application.Dialogs(xlDialogSaveAs).Show
End Sub

Robin Hammond
www.enhanceddatasystems.com

"Larry Dodd" wrote in message
...
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