Workbook_BeforeSave
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Static blnSaving As Boolean
Dim strFileName As String
If blnSaving Then
blnSaving = False
Else
Cancel = True
If MsgBox("Are sure you want to save this workbook?", vbYesNo) =
vbYes Then
strFileName = Application.GetSaveAsFilename("TCR" & Cells(20,
29) & ".xls", _
fileFilter:="Excel Files (*.xls),*.xls")
If strFileName < "False" Then
blnSaving = True
ThisWorkbook.SaveAs strFileName
End If
End If
End If
End Sub
"Bill Oertell" wrote in message
...
I'm having trouble getting this code to work. The dialog box come up and
you can navigate to the directory you want, but the file still saves to
the
original file name in the original directory.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
a = MsgBox("Are sure you want to save this workbook?", vbYesNo)
If a = vbNo Then
Cancel = True
Else
SaveAsUI = True
fileSaveName = Application.GetSaveAsFilename("TCR" & Cells(20, 29)
&
".xls", fileFilter:="Excel Files (*.xls),*.xls")
End If
End sub
What I want to do is force the user to save the file as TCR plus whatever
is
in cell AC20, ie TCRSomeone.xls, but I'd like them to be able to save it
in
the directory they choose.
|