J
joel.brewster
All,
I know that this has been asked a number of times in other posts, but I
have yet to put it together in the context that I need. I am using
Excel97 on XP. I would like to do a SaveAs any time the user attempts
any sort of Save. My plan was to use the Workbook_BeforeSave event to
prompt the user to enter another filename each time they try to save
and process accordingly. My code is listed below. Any help would be
appreciated.
TIA,
Joel Brewster
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
On Error GoTo ErrHandler
Call SaveAsDBF
Cancel = True
ErrHandler:
If Err.Number <> 0 Then
Cancel = True
End If
End Sub
Public Sub SaveAsDBF()
Dim strFileName As String
On Error GoTo ErrHandler
strFileName = Application.GetSaveAsFilename("*.dbf", "dBase
Files (*.dbf),*.dbf", 7, "Save DBF")
If UCase(strFileName) <> "FALSE" Then
Application.EnableEvents = False
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:=strFileName,
FileFormat:=xlDBF4
Application.DisplayAlerts = True
Application.EnableEvents = True
End If
ErrHandler:
If Err.Number <> 0 Then
MsgBox "Error in SaveAsDBF: " & Err.Number & " - " &
Err.Description
Err.Clear
Application.DisplayAlerts = True
Application.EnableEvents = True
End If
End Sub
I know that this has been asked a number of times in other posts, but I
have yet to put it together in the context that I need. I am using
Excel97 on XP. I would like to do a SaveAs any time the user attempts
any sort of Save. My plan was to use the Workbook_BeforeSave event to
prompt the user to enter another filename each time they try to save
and process accordingly. My code is listed below. Any help would be
appreciated.
TIA,
Joel Brewster
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
On Error GoTo ErrHandler
Call SaveAsDBF
Cancel = True
ErrHandler:
If Err.Number <> 0 Then
Cancel = True
End If
End Sub
Public Sub SaveAsDBF()
Dim strFileName As String
On Error GoTo ErrHandler
strFileName = Application.GetSaveAsFilename("*.dbf", "dBase
Files (*.dbf),*.dbf", 7, "Save DBF")
If UCase(strFileName) <> "FALSE" Then
Application.EnableEvents = False
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs FileName:=strFileName,
FileFormat:=xlDBF4
Application.DisplayAlerts = True
Application.EnableEvents = True
End If
ErrHandler:
If Err.Number <> 0 Then
MsgBox "Error in SaveAsDBF: " & Err.Number & " - " &
Err.Description
Err.Clear
Application.DisplayAlerts = True
Application.EnableEvents = True
End If
End Sub