Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Save Date in File Name

Hi I have the code below, this works fine apart from Range B6 is in the
format DD/MM/YY, I need this to change as you can't save a file with "/" in
the title.

I dont want to change the format of the Cell as Many users will be accessing
this and will all enter the date differently.

Any ideas how to add it in to my code to change the date automatically.

Cheers
Duncan

Dim WB As Workbook
Dim SH As Worksheet
Const sPath As String = "C:\Duncan\"
Set WB = ActiveWorkbook

WB.SaveAs Filename:=sPath & Range("A18").Value & " " & Range("D9").Value
& " " & Range("B6").Value, FileFormat:=xlWorkbookNormal
MsgBox "Thank you, Your Memo has been sent to Payroll & a Copy of has
been saved In: T:\Permgmt\GENTECH\GENERAL\Shared Service\Memos\ PRESS OK
TO RETURN TO THE MEMO GUIDE", vbInformation, "HEAD OFFICE - Payroll Documents"
ActiveWindow.Close
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 523
Default Save Date in File Name

Change

Range("B6").Value

to

Replace(Range("B6").Value, "/" , "." )

You don't have to use "." obviously, you can have any valid symbol you want.

Sam

"Duncan" wrote:

Hi I have the code below, this works fine apart from Range B6 is in the
format DD/MM/YY, I need this to change as you can't save a file with "/" in
the title.

I dont want to change the format of the Cell as Many users will be accessing
this and will all enter the date differently.

Any ideas how to add it in to my code to change the date automatically.

Cheers
Duncan

Dim WB As Workbook
Dim SH As Worksheet
Const sPath As String = "C:\Duncan\"
Set WB = ActiveWorkbook

WB.SaveAs Filename:=sPath & Range("A18").Value & " " & Range("D9").Value
& " " & Range("B6").Value, FileFormat:=xlWorkbookNormal
MsgBox "Thank you, Your Memo has been sent to Payroll & a Copy of has
been saved In: T:\Permgmt\GENTECH\GENERAL\Shared Service\Memos\ PRESS OK
TO RETURN TO THE MEMO GUIDE", vbInformation, "HEAD OFFICE - Payroll Documents"
ActiveWindow.Close

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Save Date in File Name

Use the Format() function so that you can adjust that to a fixed format which
you would like to..

Msgbox Format(Range("B6").Value,"mmddyyyy")
OR
Msgbox Format(Range("B6").Value,"mmmddyy")

If this post helps click Yes
---------------
Jacob Skaria


"Duncan" wrote:

Hi I have the code below, this works fine apart from Range B6 is in the
format DD/MM/YY, I need this to change as you can't save a file with "/" in
the title.

I dont want to change the format of the Cell as Many users will be accessing
this and will all enter the date differently.

Any ideas how to add it in to my code to change the date automatically.

Cheers
Duncan

Dim WB As Workbook
Dim SH As Worksheet
Const sPath As String = "C:\Duncan\"
Set WB = ActiveWorkbook

WB.SaveAs Filename:=sPath & Range("A18").Value & " " & Range("D9").Value
& " " & Range("B6").Value, FileFormat:=xlWorkbookNormal
MsgBox "Thank you, Your Memo has been sent to Payroll & a Copy of has
been saved In: T:\Permgmt\GENTECH\GENERAL\Shared Service\Memos\ PRESS OK
TO RETURN TO THE MEMO GUIDE", vbInformation, "HEAD OFFICE - Payroll Documents"
ActiveWindow.Close

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Save Date in File Name

Brilliant, worked a treat!

Thanks very much

"Sam Wilson" wrote:

Change

Range("B6").Value

to

Replace(Range("B6").Value, "/" , "." )

You don't have to use "." obviously, you can have any valid symbol you want.

Sam

"Duncan" wrote:

Hi I have the code below, this works fine apart from Range B6 is in the
format DD/MM/YY, I need this to change as you can't save a file with "/" in
the title.

I dont want to change the format of the Cell as Many users will be accessing
this and will all enter the date differently.

Any ideas how to add it in to my code to change the date automatically.

Cheers
Duncan

Dim WB As Workbook
Dim SH As Worksheet
Const sPath As String = "C:\Duncan\"
Set WB = ActiveWorkbook

WB.SaveAs Filename:=sPath & Range("A18").Value & " " & Range("D9").Value
& " " & Range("B6").Value, FileFormat:=xlWorkbookNormal
MsgBox "Thank you, Your Memo has been sent to Payroll & a Copy of has
been saved In: T:\Permgmt\GENTECH\GENERAL\Shared Service\Memos\ PRESS OK
TO RETURN TO THE MEMO GUIDE", vbInformation, "HEAD OFFICE - Payroll Documents"
ActiveWindow.Close

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
Save file as todays date Rinto Syah Excel Discussion (Misc queries) 4 May 4th 09 11:39 AM
Recovering File Info Specifically Save Date or Print Date Gadgetgw Excel Discussion (Misc queries) 4 October 6th 08 08:43 PM
Save file with last month date on end Les Excel Programming 3 May 29th 08 12:28 PM
Macro to save Excel file with date and time in the file name? sonic_d_hog Excel Programming 2 January 5th 06 05:57 PM
VB Script file save as with date nixter Excel Programming 3 January 13th 05 07:06 PM


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