Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Save with New Filename
Hi,
I have written some code and at the end I want my workbook to be saved with an altered name, and then close the workbook. i.e. the macro has finished running on previously saved file named "Test File 2.xls", i want the end of my macro to call this file "Test File 2 - altered.xls", and save it in the same location as the original file and then close the workbook. Any suggestions? Thanks, |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Save with New Filename
Put the following command line at the end of your macro:
Activeworkbook.SaveAs "Test File 2 - altered" The xls extension will automatically be added and it will use the current directory as the save location. -- Kevin Backmann "Louise" wrote: Hi, I have written some code and at the end I want my workbook to be saved with an altered name, and then close the workbook. i.e. the macro has finished running on previously saved file named "Test File 2.xls", i want the end of my macro to call this file "Test File 2 - altered.xls", and save it in the same location as the original file and then close the workbook. Any suggestions? Thanks, |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA - Save with New Filename
and it will use the current directory as the save location.
But she wants to use the workbook's path, which might be different. so maybe: Sub a() Dim PathStr As String PathStr = ActiveWorkbook.Path If Right(PathStr, 1) < "\" Then PathStr = PathStr & "\" End If ActiveWorkbook.SaveAs PathStr & "Test File 2 - altered" End Sub -- Jim "Kevin B" wrote in message ... Put the following command line at the end of your macro: Activeworkbook.SaveAs "Test File 2 - altered" The xls extension will automatically be added and it will use the current directory as the save location. -- Kevin Backmann "Louise" wrote: Hi, I have written some code and at the end I want my workbook to be saved with an altered name, and then close the workbook. i.e. the macro has finished running on previously saved file named "Test File 2.xls", i want the end of my macro to call this file "Test File 2 - altered.xls", and save it in the same location as the original file and then close the workbook. Any suggestions? Thanks, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Cell("filename") doesn't update to new filename when do save as. | Excel Worksheet Functions | |||
Doing a save with a variable filename? | Excel Programming | |||
save as different filename | Excel Programming | |||
Save Filename | Excel Programming | |||
save as filename | Excel Programming |