Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excell macro Date help

I made a macro to perform a "save as" and give it a file name as you see
below. I now need it to create the file name based on the date ...

ActiveWorkbook.SaveAs "c:\mypath\currentdump.xls"

I need it to save the file as the followint format.. (replace the mmddyyyy
with the date...)

ActiveWorkbook.SaveAs "c:\mypath\mmddyyyy.xls"

What do I need to do to accomplish this?

Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Excell macro Date help

ActiveWorkbook.SaveAs "c:\mypath\" & Format(Date,"mmddyyyy") & ".xls"


--

John Green - Excel MVP
Sydney
Australia


"Tim_S" wrote in message ...
I made a macro to perform a "save as" and give it a file name as you see
below. I now need it to create the file name based on the date ...

ActiveWorkbook.SaveAs "c:\mypath\currentdump.xls"

I need it to save the file as the followint format.. (replace the mmddyyyy
with the date...)

ActiveWorkbook.SaveAs "c:\mypath\mmddyyyy.xls"

What do I need to do to accomplish this?

Thanks




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Excell macro Date help

I would suggest you use

ActiveWorkbook.SaveAs "c:\mypath\" & Format(Date,"yyyymmdd") & ".xls"

so that if you sort the files created they are sorted in data order with
all the files for this year sorted before any files for next year - and all
files for Jan this year are sorted before the ones for Feb. Your way
with mmddyy will sort all files from Jan in any year before any files
for any other month.

Chrissy/



"John Green" wrote in message ...
ActiveWorkbook.SaveAs "c:\mypath\" & Format(Date,"mmddyyyy") & ".xls"


--

John Green - Excel MVP
Sydney
Australia


"Tim_S" wrote in message ...
I made a macro to perform a "save as" and give it a file name as you see
below. I now need it to create the file name based on the date ...

ActiveWorkbook.SaveAs "c:\mypath\currentdump.xls"

I need it to save the file as the followint format.. (replace the mmddyyyy
with the date...)

ActiveWorkbook.SaveAs "c:\mypath\mmddyyyy.xls"

What do I need to do to accomplish this?

Thanks






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excell macro Date help

Ok this works great.

Now another big question is how can I tell if an Excel document is open and
locked before I do a save as

For instance;
I have 1.xls open and want to save it as 2.xls but joe another user has
2.xls open. I get an error in the macro when the macro tries to save it.

Thanks




"Tim_S" wrote in message
...
I made a macro to perform a "save as" and give it a file name as you see
below. I now need it to create the file name based on the date ...

ActiveWorkbook.SaveAs "c:\mypath\currentdump.xls"

I need it to save the file as the followint format.. (replace the mmddyyyy
with the date...)

ActiveWorkbook.SaveAs "c:\mypath\mmddyyyy.xls"

What do I need to do to accomplish this?

Thanks




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Excell macro Date help

You should first consider the logic behind one used trying to
save a document to a name that another user has already used.
This implies that you need to come up with some naming
conventions which will give unique names or come up with
a procedure for deciding which document is the real 2.xls.

Having said that - the easiest way to do what you want to do
is with error trapping.

Try to do what you want and if it fails then check why it failed
and if it failed because it was already opened or existed the you
take appropriate action. Of course, depending on your answers
to the above, there may very well be a better solution for you.

Chrissy.



Tim_S wrote
Ok this works great.

Now another big question is how can I tell if an Excel document is open and
locked before I do a save as

For instance;
I have 1.xls open and want to save it as 2.xls but joe another user has
2.xls open. I get an error in the macro when the macro tries to save it.



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
Macro Excell 03/07 Mike Excel Discussion (Misc queries) 2 January 5th 10 01:13 AM
Excell Macro Help Please Bill Kirk New Users to Excel 2 January 25th 06 09:22 PM
converting Lotus 123 macro to Excell macro mark h Excel Discussion (Misc queries) 6 July 11th 05 01:28 PM
Macro Text into Excell Krefty Excel Discussion (Misc queries) 2 December 20th 04 09:14 PM
macro crashes excell xp Todd[_5_] Excel Programming 2 September 5th 03 07:10 PM


All times are GMT +1. The time now is 11:03 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"