Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
Dim DialogResult As String
Dim UserFileName As String
Dim sAppPath As String
Dim sFile as String
On Error goto ErrHandler
Application.EnableEvents = False
Cancel = True
sAppPath = ActiveWorkbook.Path & _
"\Bone Match 5.0 Template Directory\" & _
"Bone Match 5.0 History\"
sFile = "BoneMatch.xls"
chDrive sAppPath
chdir sAppPath
DialogResult = Application.GetSaveAsFilename( _
InitialFileName:=sAppPath & sFile, _
FileFilter:="Microsoft Office Excel Workbook (*.xls), *.xls")
If DialogResult = "False" Then
Application.EnableEvents = True
Exit Sub
End If
If lcase(ThisWorkbook.FullName) = lcase(DialogResult) Then
msgbox "Must change name. Save Cancelled"
Application.EnableEvents = True
Exit Sub
End if
Workbook.SaveAs DialogResult
ErrHandler:
Application.EnableEvents = True
End Sub
This assumes the directory you selected exists. In any event, you always
want to set Cancel = True