• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

Adding Time Stamp to File Save

I have been using the following file SaveAs process, but recently found that when saving if someone else has the file open, it fails.  How would I add a time stamp to the file save as to prevent this from happening?  I have some cases were I was overwritting the previous file with the new current file, but see that is not going to work.


Sub SaveFileToWDrive()
Dim FName As String
'
 FName = "W:\Holland\rrw5\Bruce Shortage Report "
 FName = FName & Format(Date, "ddmmmyy") & ".xlsx"
    'ChDir "W:\Holland\rrw5"
    ActiveWorkbook.SaveAs Filename:= _
        FName, FileFormat:= _
        xlOpenXMLWorkbook, CreateBackup:=False
    ActiveWorkbook.Close
    MsgBox ("File Saved to " & FName)
    
End Sub

Open in new window

0
RWayneH
Asked:
RWayneH
  • 2
1 Solution
 
Rgonzo1971Commented:
HI,

pls try

Format(Date, "ddmmmyy") & "_" & Format(Time, "HHMM")

Open in new window

Regards
0
 
RWayneHAuthor Commented:
I may have got this to work, however I need a few more days to test.
0
 
RWayneHAuthor Commented:
Thanks for the help -R-
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now