Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Trouble saving a worsheet to a file using macros.

I have set up a macro using the following code to save my worksheet as a
seperate file using the days date as the filename eg 21012005.xls

Sheets("*****").Copy
strAppend = Format(Date, "DDMMYYYY")
strPath = "*****"
fSaveName = strPath & strAppend & ".xls"
ActiveWorkbook.SaveAs fSaveName
ActiveWorkbook.Close

I would like to put in a code that says if that file (21012005.xls) all
ready exists, add an "a" after the date,eg "21012005a.xls".

Can this be done? I'm only new to using macros and any help would be greatly
appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Trouble saving a worsheet to a file using macros.

Sheets("*****").Copy
strAppend = Format(Date, "DDMMYYYY")
strPath = "*****"
fSaveName = strPath & strAppend & ".xls"
if dir(fSaveName) < "" then
fSaveName = strPath & strAppend & "a.xls"
End If
ActiveWorkbook.SaveAs fSaveName
ActiveWorkbook.Close

--
Regards,
Tom Ogilvy


"phoenixx153" wrote in message
...
I have set up a macro using the following code to save my worksheet as a
seperate file using the days date as the filename eg 21012005.xls

Sheets("*****").Copy
strAppend = Format(Date, "DDMMYYYY")
strPath = "*****"
fSaveName = strPath & strAppend & ".xls"
ActiveWorkbook.SaveAs fSaveName
ActiveWorkbook.Close

I would like to put in a code that says if that file (21012005.xls) all
ready exists, add an "a" after the date,eg "21012005a.xls".

Can this be done? I'm only new to using macros and any help would be

greatly
appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Trouble saving a worsheet to a file using macros.

Thank you very much Tom.
I appreciate it immensly

"Tom Ogilvy" wrote:

Sheets("*****").Copy
strAppend = Format(Date, "DDMMYYYY")
strPath = "*****"
fSaveName = strPath & strAppend & ".xls"
if dir(fSaveName) < "" then
fSaveName = strPath & strAppend & "a.xls"
End If
ActiveWorkbook.SaveAs fSaveName
ActiveWorkbook.Close

--
Regards,
Tom Ogilvy


"phoenixx153" wrote in message
...
I have set up a macro using the following code to save my worksheet as a
seperate file using the days date as the filename eg 21012005.xls

Sheets("*****").Copy
strAppend = Format(Date, "DDMMYYYY")
strPath = "*****"
fSaveName = strPath & strAppend & ".xls"
ActiveWorkbook.SaveAs fSaveName
ActiveWorkbook.Close

I would like to put in a code that says if that file (21012005.xls) all
ready exists, add an "a" after the date,eg "21012005a.xls".

Can this be done? I'm only new to using macros and any help would be

greatly
appreciated.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default Trouble saving a worsheet to a file using macros.

Tom, can I add an additional Q. here?
Can your modify your code so that the new created "DDMMYYYY.xls" formatted
file will not contain the original file macro codes and possible control
button figures on the copied sheet?
Regards
J_J

"Tom Ogilvy" wrote in message
...
Sheets("*****").Copy
strAppend = Format(Date, "DDMMYYYY")
strPath = "*****"
fSaveName = strPath & strAppend & ".xls"
if dir(fSaveName) < "" then
fSaveName = strPath & strAppend & "a.xls"
End If
ActiveWorkbook.SaveAs fSaveName
ActiveWorkbook.Close

--
Regards,
Tom Ogilvy


"phoenixx153" wrote in message
...
I have set up a macro using the following code to save my worksheet as a
seperate file using the days date as the filename eg 21012005.xls

Sheets("*****").Copy
strAppend = Format(Date, "DDMMYYYY")
strPath = "*****"
fSaveName = strPath & strAppend & ".xls"
ActiveWorkbook.SaveAs fSaveName
ActiveWorkbook.Close

I would like to put in a code that says if that file (21012005.xls) all
ready exists, add an "a" after the date,eg "21012005a.xls".

Can this be done? I'm only new to using macros and any help would be

greatly
appreciated.





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
Trouble opening an Excel file that contains macros JohnR Excel Worksheet Functions 1 March 8th 05 08:09 PM
Macros making file saving extremely slow. Donald Speirs Excel Discussion (Misc queries) 1 January 20th 05 10:10 PM
Macros make file saving extremely slow. JE McGimpsey Excel Programming 0 January 20th 05 05:09 PM
control box, macro security and trouble saving a file Julie N. in Iowa Excel Programming 1 December 16th 04 06:01 PM
Saving file without macros Paul_Russell[_3_] Excel Programming 3 February 26th 04 04:26 PM


All times are GMT +1. The time now is 06:52 AM.

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"