LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
PGM PGM is offline
external usenet poster
 
Posts: 5
Default How to change closed file name - Error: file not found

Hello,

I've been trying to write code in Excel 2003 to change the name of a
closed file. This is to prevent a new version of a form from
overwriting the old file. I used the code provided by Tom Ogilvy back
in 2004 (in addition to another function whose author name I don't
currently have handy), but every time I try to run the macro, I get an
error message that the file is not found. An example of my code is
shown below:

MyState, MyAgyNum, MyYear and MyWorkbook have been previously defined
via userform.

' File name.
sName = "S:\Dept\GROUP\CITY\STATE\Auto Agency Reports\" & MyState &
" Auto Reports\" & MyAgyNum & "\" & MyYear & "\VERSION\" & MyWorkbook &
".xls"
If Dir(sName) < "" Then

' Get properties with Function: File_Created_Info.
MyCreated =
File_Created_Info("S:\Dept\GROUP\CITY\STATE\Auto Agency Reports\" &
MyState & " Auto Reports\" & MyAgyNum & "\" & MyYear & "\VERSION\" &
MyWorkbook & ".xls")

' Identify Date and Time.
MyDate = Left(MyCreated, InStr(MyCreated, " ") - 1)
MyTime = Format(Right(MyCreated, Len(MyCreated) -
InStr(MyCreated, " ")), "hh:mm;@")

' Format time for file name.
MyTime = Left(MyTime, 2) & "." & Right(MyTime, 2)

' Identify file to change.
oldfile = "S:\Dept\GROUP\CITY\STATE\Auto Agency Reports\" &
MyState & " Auto Reports\" & MyAgyNum & "\" & MyYear & "\VERSION\" &
MyWorkbook & ".xls"

' Identify if existing file created on current date.
If Format(Date, "m-d-yy") = MyDate Then
NewFile = "S:\Dept\GROUP\CITY\STATE\Auto Agency
Reports\" & MyState & " Auto Reports\" & MyAgyNum & "\" & MyYear &
"\VERSION\" & MyWorkbook & " (" & MyDate & " " & MyTime & ").xls"
Else:
NewFile = "S:\Dept\GROUP\CITY\STATE\Auto Agency
Reports\" & MyState & " Auto Reports\" & MyAgyNum & "\" & MyYear &
"\VERSION\" & MyWorkbook & " (" & MyDate & ").xls"
End If

' This is what fails every time.<<<<<<<
Name oldfile As NewFile

Thanks in advance for any help you can provide.

 
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
R/T error 53 - File Not Found JMay Excel Discussion (Misc queries) 4 October 22nd 08 02:56 PM
Installation Error: File Not Found I h8 sku112.cab New Users to Excel 2 September 25th 08 10:58 PM
Runtime Error '53' File Not Found? et10yl Excel Discussion (Misc queries) 0 November 27th 06 10:49 PM
File not found - error Piranha[_39_] Excel Programming 18 September 19th 05 02:18 AM
"file not found" error message when launching source file Lisa[_9_] Excel Programming 4 April 6th 04 02:54 PM


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