Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default saving And rename source file

Hello
I have a module that opens a master file that I get data from. is there a
way to save the file in a different location with the date at the end of the
file?
the source is
C:\Documents and Settings\My Documents\Reports\Master 2010.XLS
I would like it to be
C:\Documents and Settings\My Documents\Saved Reports\OCPOC - Master 2010 -
Date.XLS
Also if there is a file with the same date add a number of file

Thanks,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default saving And rename source file

'/===============================/
Sub SaveMyFile()
Dim blnFileExists As Boolean
Dim i As Integer
Dim strSave2File As String

'set up default value for whether file exists
blnFileExists = False

'create the name/location of file to be saved
strSave2File = _
"C:\Documents and Settings\My Documents\" & _
"Saved Reports\OCPOC - Master 2010 -" & _
Format(Date, "yyyy_mm_dd") & _
".xls"

'check whether file exists.
' If no - continue
' If yes - add # to filename and check again
Do
'call private UDF below to see if file already exists
blnFileExists = FileExists(strSave2File)
If blnFileExists = True Then
i = i + 1
strSave2File = _
Left(strSave2File, Len(strSave2File) - 4) & i & ".xls"
Else
'if file does NOT exist, continue on
Exit Do
End If
Loop

'save the file
ActiveWorkbook.SaveAs Filename:=strSave2File, _
FileFormat:=xlNormal, Password:= _
"", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

End Sub
'/===============================/
Private Function FileExists(strFileName As String) _
As Boolean
FileExists = False
If Dir(strFileName) < "" Then
FileExists = True
End If
End Function
'/===============================/

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown



"trigunner" wrote:

Hello
I have a module that opens a master file that I get data from. is there a
way to save the file in a different location with the date at the end of the
file?
the source is
C:\Documents and Settings\My Documents\Reports\Master 2010.XLS
I would like it to be
C:\Documents and Settings\My Documents\Saved Reports\OCPOC - Master 2010 -
Date.XLS
Also if there is a file with the same date add a number of file

Thanks,

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
I learned how to rename workbook without saving it Yar Glazkov Excel Programming 20 June 16th 09 07:58 PM
How to rename workbook that I am editing without saving? [email protected] Excel Discussion (Misc queries) 1 March 23rd 08 04:00 PM
How to copy a sheet and rename it with the value of two cells from the source sheet? Simon Lloyd[_717_] Excel Programming 0 May 12th 06 01:31 AM
How to set SAVE AS file name to equal A1 contents when rename file E Excel Discussion (Misc queries) 0 October 19th 05 08:36 PM
Saving a Workbook: Forcing User to Rename before Saving Rollin_Again[_6_] Excel Programming 5 April 16th 04 02:54 PM


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