Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I created a simple formatting macro and included the "save As" in the macro,
of course it wants to save the workbook as the name indicated in the macro. Can I have the macro save the workbook as the current workbook name? |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Are you saving the workbook with the code?
Do you want to overwrite the existing workbook? If yes to both, you can use: thisworkbook.save If you want to save a different workbook with the same name as the workbook that's running the code, then nope--you can't use Save|As. You can only have one file open with any particular name. There may be other work arounds. You could save the file with a temporary name. Close that file. And then use the Name statement to rename it to what you want. There are other things to consider, too. Is the workbook opened readonly? Are you trying to use the same drive/path/filename or what???? Mark wrote: I created a simple formatting macro and included the "save As" in the macro, of course it wants to save the workbook as the name indicated in the macro. Can I have the macro save the workbook as the current workbook name? -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
The file is originally a .csv file that i am formatting and then saving as an
..xls file using the same file name, in the same folder and directory. "Dave Peterson" wrote: Are you saving the workbook with the code? Do you want to overwrite the existing workbook? If yes to both, you can use: thisworkbook.save If you want to save a different workbook with the same name as the workbook that's running the code, then nope--you can't use Save|As. You can only have one file open with any particular name. There may be other work arounds. You could save the file with a temporary name. Close that file. And then use the Name statement to rename it to what you want. There are other things to consider, too. Is the workbook opened readonly? Are you trying to use the same drive/path/filename or what???? Mark wrote: I created a simple formatting macro and included the "save As" in the macro, of course it wants to save the workbook as the name indicated in the macro. Can I have the macro save the workbook as the current workbook name? -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Note quite the same name (the extensions are different). So it's not a problem.
Option Explicit Sub testme() Dim myFileName As String With ActiveWorkbook 'strip off the extension: .csv myFileName = Left(.FullName, Len(.FullName) - 4) 'add the new extension: .xls myFileName = myFileName & ".xls" .SaveAs Filename:=myFileName, FileFormat:=xlWorkbookNormal .Close savechanges:=False 'maybe??? End With End Sub Mark wrote: The file is originally a .csv file that i am formatting and then saving as an .xls file using the same file name, in the same folder and directory. "Dave Peterson" wrote: Are you saving the workbook with the code? Do you want to overwrite the existing workbook? If yes to both, you can use: thisworkbook.save If you want to save a different workbook with the same name as the workbook that's running the code, then nope--you can't use Save|As. You can only have one file open with any particular name. There may be other work arounds. You could save the file with a temporary name. Close that file. And then use the Name statement to rename it to what you want. There are other things to consider, too. Is the workbook opened readonly? Are you trying to use the same drive/path/filename or what???? Mark wrote: I created a simple formatting macro and included the "save As" in the macro, of course it wants to save the workbook as the name indicated in the macro. Can I have the macro save the workbook as the current workbook name? -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Need step by step to add invoice numbering to excel template | New Users to Excel | |||
How do I put worksheets in a workbook in alpha order in 1 step | Excel Worksheet Functions | |||
Saving Macro to Personal Workbook | Excel Discussion (Misc queries) | |||
Macro Step by Step | Excel Discussion (Misc queries) | |||
I need step by step instructions to create a macro for 10 imbedde. | Excel Worksheet Functions |