Maybe you can disable any saving and just provide a macro to save to the
location of your choice.
This all depends on macros being enabled and events being enabled.
Behind the ThisWorkbook module:
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
MsgBox "Not Saved!!!" & vbLf & "Please use the button to save!"
End Sub
And provide them some way of saving the workbook (a button from the Forms
toolbar on the worksheet???).
In fact, some of "forms" I've worked with use a cell in that worksheet as a
placeholder for the filename.
Maybe you can do something like that (or modify this to get the filename some
other way):
Behind a general module:
Option Explicit
Sub SpecialSave()
Dim myFileName As String
Dim myPath As String
Dim TestStr As String
Dim resp As Long
Dim myErrNumber As Long
Dim myErrDesc As String
myPath = "C:\temp\"
myFileName = ActiveSheet.Range("a1").Value
'some minor checks
If Trim(myFileName) = "" Then
MsgBox "Please put something in the filename cell!"
Exit Sub
End If
If InStr(1, myFileName, "\", vbTextCompare) > 0 _
Or InStr(1, myFileName, "/", vbTextCompare) > 0 Then
MsgBox "Please fix the filename cell!"
Exit Sub
End If
If LCase(Right(myFileName, 4)) = ".xls" Then
'ok
Else
myFileName = myFileName & ".xls"
End If
myFileName = myPath & myFileName
'check for existing files with that name
TestStr = ""
On Error Resume Next
TestStr = Dir(myFileName)
On Error GoTo 0
If TestStr = "" Then
'no existing files with that name
Else
resp = MsgBox(Prompt:="Overwrite existing file?", Buttons:=vbYesNo)
If resp = vbNo Then
MsgBox "File not saved!"
Exit Sub
End If
End If
'try to save it
On Error Resume Next
Application.EnableEvents = False
Application.DisplayAlerts = False
ThisWorkbook.SaveAs FileName:=myFileName, FileFormat:=xlWorkbookNormal
myErrNumber = Err.Number
myErrDesc = Err.Description
Err.Clear
Application.DisplayAlerts = True
Application.EnableEvents = True
On Error GoTo 0
If myErrNumber = 0 Then
MsgBox "File saved to: " & ThisWorkbook.FullName
Else
MsgBox "File Not Saved" & vbLf & myErrNumber & vbLf & myErrDesc
End If
End Sub