tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,194
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
I have this macro to open the save as dialog box and save the document as a new name,
It works great except people keep saving it as the defualt wording (I know right!)
so i want to add a bit of macro that says if the name you are trying to save at is " " then dont let them,
please help if you can
here my macro
thanks
Tony
I have this macro to open the save as dialog box and save the document as a new name,
It works great except people keep saving it as the defualt wording (I know right!)
so i want to add a bit of macro that says if the name you are trying to save at is " " then dont let them,
please help if you can
here my macro
VBA Code:
Sub SaveFile()
Dim FileName As Variant
FileName = Application.GetSaveAsFilename("Type New File Name Here", _
"Excel files,*.xlsm", 1, "Select your folder and filename")
If TypeName(FileName) = "Boolean" Then
MsgBox "User cancelled", vbCritical, "File Not Saved!"
Exit Sub
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' THIS BIT DOES NOT WORK!
If FileName = "Type New File Name Here.xlsm" Then
MsgBox "Can't use this name, please try again", vbCritical, "File Not Saved!"
Exit Sub
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
ActiveWorkbook.SaveAs FileName
End Sub
thanks
Tony