ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA - Save with new filename (https://www.excelbanter.com/excel-programming/375035-vba-save-new-filename.html)

Louise

VBA - Save with new filename
 
Hi,

I have a macro which runs lots of changes on an excel file, the one thing i
am unsure on how to do is to get the end of the macro to save the file with
an altered name in the same location as the original file, then close the
workbook.

e.g.

The file is named "Test File 2.xls", and I want it to be called "Test File 2
- altered.xls", to be saved in the same location as the original file, then
for the workbook to close.

Any suggestions?

Thanks,

Incidental

VBA - Save with new filename
 
Hi

You could use SaveCopyAs

Dim StrPath As String
Dim StrName As String

StrPath = "C:\Place\You\Want\To\Save"
StrName = "Test File 2 - Altered.xls"
ActiveWorkbook.SaveCopyAs StrPath & "\" & StrName
MsgBox "Save Complete", vbOKOnly, "Back UPs"

Hope this helps

S


Louise wrote:
Hi,

I have a macro which runs lots of changes on an excel file, the one thing i
am unsure on how to do is to get the end of the macro to save the file with
an altered name in the same location as the original file, then close the
workbook.

e.g.

The file is named "Test File 2.xls", and I want it to be called "Test File 2
- altered.xls", to be saved in the same location as the original file, then
for the workbook to close.

Any suggestions?

Thanks,




All times are GMT +1. The time now is 07:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com