Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Recording macro to save file with name change

I have recorded a macro that will make multiple formatting changes to a .csv
file and then save it in a new directory.

The newly created file will have a new file name each day based on the
current date. For example, todays new file is "Outbound 02-22-07" and
tomorrows will be "Outbound 02-23-07" etc.

But when I look in the VBA editor, the code is specific to the file name at
the time the macro was recorded.

Is there a way to have the macro save it with a variable filename as I have
outlined above?

Any help would be appreciated - this is my jump into using macro's.

With Best Regards,


Jon
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default Recording macro to save file with name change

replace the line with the hard-coded filename to something like:

ActiveWorkbook.SaveAs "Outbound " & Format (Now, "mm-dd-yy")


On Feb 22, 2:38 pm, jmcclain
wrote:
I have recorded a macro that will make multiple formatting changes to a .csv
file and then save it in a new directory.

The newly created file will have a new file name each day based on the
current date. For example, todays new file is "Outbound 02-22-07" and
tomorrows will be "Outbound 02-23-07" etc.

But when I look in the VBA editor, the code is specific to the file name at
the time the macro was recorded.

Is there a way to have the macro save it with a variable filename as I have
outlined above?

Any help would be appreciated - this is my jump into using macro's.

With Best Regards,

Jon



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Recording macro to save file with name change

activeworkbook.SaveAs "C:\Myfolder\Outbound " & format(date,"mm-dd-yy") &
".csv", xlCSV

or to save it as a workbook:

activeworkbook.SaveAs "C:\Myfolder\Outbound " & format(date,"mm-dd-yy") &
".xls", xlWorkbook

--
Regards,
Tom Ogilvy



"jmcclain" wrote:

I have recorded a macro that will make multiple formatting changes to a .csv
file and then save it in a new directory.

The newly created file will have a new file name each day based on the
current date. For example, todays new file is "Outbound 02-22-07" and
tomorrows will be "Outbound 02-23-07" etc.

But when I look in the VBA editor, the code is specific to the file name at
the time the macro was recorded.

Is there a way to have the macro save it with a variable filename as I have
outlined above?

Any help would be appreciated - this is my jump into using macro's.

With Best Regards,


Jon

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
Recording a macro to change item selected in drop down list Jen Excel Worksheet Functions 2 October 2nd 08 11:37 PM
Saving a file while recording a macro Richard Champlin Excel Discussion (Misc queries) 6 September 1st 07 01:08 AM
how do I change macro relative reference? no stop recording tool G Excel Discussion (Misc queries) 1 November 11th 06 08:09 PM
Recording a macro to open a large fixed-width text file Lucie Harris Excel Programming 3 September 1st 04 02:23 AM
Save File to Another Directory, but not change Users File Save location Mike Knight Excel Programming 1 May 28th 04 09:06 PM


All times are GMT +1. The time now is 11:22 PM.

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

About Us

"It's about Microsoft Excel"