Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 989
Default Saving a workbook step in a Macro

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Saving a workbook step in a Macro

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 989
Default Saving a workbook step in a Macro

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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Saving a workbook step in a Macro

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need step by step to add invoice numbering to excel template rmt New Users to Excel 4 July 6th 08 11:45 PM
How do I put worksheets in a workbook in alpha order in 1 step Lynette Excel Worksheet Functions 1 March 15th 08 05:46 PM
Saving Macro to Personal Workbook Chris Excel Discussion (Misc queries) 1 November 8th 06 08:41 PM
Macro Step by Step fak119 Excel Discussion (Misc queries) 2 August 31st 06 08:11 AM
I need step by step instructions to create a macro for 10 imbedde. diana Excel Worksheet Functions 3 January 31st 05 01:56 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"