Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Saveas with date problem


Hi i have a procedure that copys data into a workbook from external
locations, i need to save this workbook under todays date to create an
audit trail. I'm having problems doing this as running the code brings
up error 1004 - excel cannot access the file because doesn't exist,
used by someone else.

What is wrong, code is below, thanks

Dim fname As String

fname = "Mainfile-" & Format(Date, "dd/mm/yyyy")
ActiveWorkbook.SaveAs Filename:=fname
MsgBox (fname)


--
cereldine
------------------------------------------------------------------------
cereldine's Profile: http://www.excelforum.com/member.php...o&userid=32069
View this thread: http://www.excelforum.com/showthread...hreadid=539204

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default Saveas with date problem

You are using slashes in your file name, which isn't allowed - they
indicate a new directory - so try

"mainfile-" & format(date,"dd-mm-yyyy")

should do it for you!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default Saveas with date problem

Can't do / in a filename, and you should start with the date in reverse
order, for sorting

Dim fname As String

fname = Format(Date, "yyyymmdd") & "-Mainfile"
ActiveWorkbook.SaveAs Filename:=fname
MsgBox (fname)


--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"cereldine" wrote
in message ...

Hi i have a procedure that copys data into a workbook from external
locations, i need to save this workbook under todays date to create an
audit trail. I'm having problems doing this as running the code brings
up error 1004 - excel cannot access the file because doesn't exist,
used by someone else.

What is wrong, code is below, thanks

Dim fname As String

fname = "Mainfile-" & Format(Date, "dd/mm/yyyy")
ActiveWorkbook.SaveAs Filename:=fname
MsgBox (fname)


--
cereldine
------------------------------------------------------------------------
cereldine's Profile:

http://www.excelforum.com/member.php...o&userid=32069
View this thread: http://www.excelforum.com/showthread...hreadid=539204



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Saveas with date problem


Hi Cereldine,

I normally receive a different (more informative) warning message whe
I try to save files with a date & it tells me that the reason that th
code will not allow a save is that filenames can not include th
forward slash character (ie "/"). The easiest way I know of to ge
around this is to replace it with a decimal point (ie "."), fo
example:

Dim fname As String
Dim StringDate As String
StringDate = Day(Date) & "." & Month(Date) & "." & Year(Date)
fname = "Mainfile-" & StringDate
MsgBox fname
ActiveWorkbook.SaveAs Filename:=fname
MsgBox (fname)

hth
Rob Brockett
NZ
Always leraning & the best way to learn is to experience..

--
broro18
-----------------------------------------------------------------------
broro183's Profile: http://www.excelforum.com/member.php...fo&userid=3006
View this thread: http://www.excelforum.com/showthread.php?threadid=53920

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
ActiveWorkbook.SaveAs problem SandyUK[_11_] Excel Programming 2 November 14th 05 02:54 PM
my saveas macro date problem Nigel Excel Programming 11 September 16th 05 06:51 PM
SaveAs CSV problem pittur Excel Programming 2 June 16th 05 02:22 PM
SaveAs Problem Don Lloyd Excel Programming 7 January 11th 05 10:54 AM
SaveAs problem Jessi Excel Programming 2 July 31st 03 07:36 PM


All times are GMT +1. The time now is 09:40 AM.

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"