kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
Hello [Merry Christmas]
I have this code and I need some adjustments:
1. Fill the name field with predefined name
- "My File" + current year
Which is to say that if I run the code right now, the name field should display "My File 2021"
2. When I click the Save button, I want to scan the directory where I am saving the file for the availability of same name as in the name field. And if I find a match, I want to flag a message alert.
Can someone please help me with it?
Thanks in advance.
I have this code and I need some adjustments:
1. Fill the name field with predefined name
- "My File" + current year
Which is to say that if I run the code right now, the name field should display "My File 2021"
2. When I click the Save button, I want to scan the directory where I am saving the file for the availability of same name as in the name field. And if I find a match, I want to flag a message alert.
Code:
Sub SaveFileCode
ChDrive ThisWorkbook.Path
ChDir ThisWorkbook.Path
FileSaveAs = Application.GetSaveAsFilename(FileFilter:="Exel Files (*.xlsm),*.xlsm",Title:="Add Name")
If FileSaveAs = False Then
MsgBox "Operation terminated"
Else
Application.EnableEvents=False
ThisWorkbook.SaveAs FileName:=FileSaveAs, FileFormat:=52, Password:="", writerespassword:="", ReadOnlyRecommended:=False
Application.EnableEvents=True
End Sub
Can someone please help me with it?
Thanks in advance.