I need to:
- Turn off "save" and "save as" command bars
- Prompt user for a unique filename
- Save file to a specific directory on the network common to all "p:\data\prc"
- Requery user if filename exists and if they DON'T want to overwrite.
- Return to worksheet (there is only one) if the user cancels from the message box.
- Turn commandbars back on
The macro runs from an on screen button
I get bug errors on NO or CANCEL when clicked in the message box
This is my current code:
Code
Private Sub Workbook_Open()
Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save As...").Enabled = False
Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save").Enabled = False
End Sub
Sub SaveMe()
'
' Keyboard Shortcut: Ctrl+z
'
Dim BaseDir As String
Dim NewName As String
BaseDir = "p:\data\prc"
On Error Resume Next
'Application.DisplayAlerts = False
ChDir BaseDir
NewName = Application.InputBox(Prompt:="Please enter a UNIQUE filename without the .xls.", Type:=1 + 2)
On Error GoTo 0
ActiveWorkbook.SaveAs NewName
'Application.DisplayAlerts = True
Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save As...").Enabled = True
Application.CommandBars("Worksheet Menu Bar").Controls("File").Controls("Save").Enabled = True
End Sub
Display More
I am a very proficient user of Excel but just starting out with VBA. Thank You very much.