BrianLearning
New Member
- Joined
- Jul 1, 2020
- Messages
- 3
- Office Version
- 365
- Platform
- Windows
I want to create a macro to save the file to the "July" folder in the Z drive, in a CSV format. Without changing the file name to something different.
I have the macro:
Here's the problem. It doesn't save the file to the Z drive and the July folder. It just saves the files in the folder that the file is currently in.
I have found sites suggesting I should do the following:
This works, in that it saves the file in CSV format, to the July folder in the Z drive, with the filename "Ledger_Template_final." The problem is, I don't want the macro to specify the filename. The filename should be whatever the existing name of the file is. The reason is, the macro will be used on many different files that will be saved in the July folder. We can't save them all with the same file name.
Can anyone help me please?
I have the macro:
VBA Code:
Sub Save_To_Z()
'
' Save_To_Z Macro
'
' Keyboard Shortcut: Ctrl+Shift+Z
'
ChDir "Z:\July"
ActiveWorkbook.SaveAs FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close
End Sub
Sub Macro2()
'
' Macro2 Macro
'
'
End Sub
Here's the problem. It doesn't save the file to the Z drive and the July folder. It just saves the files in the folder that the file is currently in.
I have found sites suggesting I should do the following:
VBA Code:
Sub Save_To_Z()
'
' Save_To_Z Macro
'
' Keyboard Shortcut: Ctrl+Shift+Z
'
ChDir "Z:\July"
ActiveWorkbook.SaveAs Filename:= _
"Z:\July\Ledger_Template_final.csv", _
FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close
End Sub
Sub Macro2()
'
' Macro2 Macro
'
'
End Sub
This works, in that it saves the file in CSV format, to the July folder in the Z drive, with the filename "Ledger_Template_final." The problem is, I don't want the macro to specify the filename. The filename should be whatever the existing name of the file is. The reason is, the macro will be used on many different files that will be saved in the July folder. We can't save them all with the same file name.
Can anyone help me please?