Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Is it possible to get a date stamp from an Excel file?

Hi All

I am working on an automated backup scheme where my Excel
automatically makes a copy of itself every 7 days (although this is
configurable) in a seperate backup sub folder.

At the moment I record in the spreadsheet itself the date of the last
backup but this wont always work as sometimes a user will open the
spreadsheet in read-only - I still want to make the backup but I
cannot record the date of the backup in the spreadsheet.

So I think a better approach would be to look at the files in the
backup folder and find the one with the most recent date stamp - I can
then decide based on this date whether a new backup is required.

Is it possible in Excel VB to ask for the date stamp of all files in a
folder? Does anyone have some similar code?

Cheers and thanks in advance for any ideas,
Chrisso

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Is it possible to get a date stamp from an Excel file?

give this a try
filedate is a variable and filename.xls is your filename

filedate = FileDateTime("filename.xls")

if it's not in the default path then something like this

fpath = fPath = ThisWorkbook.Path & "\"
filedate = FileDateTime(fpath & "filename.xls")




--


Gary


"Chrisso" wrote in message
oups.com...
Hi All

I am working on an automated backup scheme where my Excel
automatically makes a copy of itself every 7 days (although this is
configurable) in a seperate backup sub folder.

At the moment I record in the spreadsheet itself the date of the last
backup but this wont always work as sometimes a user will open the
spreadsheet in read-only - I still want to make the backup but I
cannot record the date of the backup in the spreadsheet.

So I think a better approach would be to look at the files in the
backup folder and find the one with the most recent date stamp - I can
then decide based on this date whether a new backup is required.

Is it possible in Excel VB to ask for the date stamp of all files in a
folder? Does anyone have some similar code?

Cheers and thanks in advance for any ideas,
Chrisso



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Is it possible to get a date stamp from an Excel file?


sorry, saw a typo
fpath = fPath = ThisWorkbook.Path & "\"
should be
fPath = ThisWorkbook.Path & "\"



--


Gary


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
give this a try
filedate is a variable and filename.xls is your filename

filedate = FileDateTime("filename.xls")

if it's not in the default path then something like this

fpath = fPath = ThisWorkbook.Path & "\"
filedate = FileDateTime(fpath & "filename.xls")




--


Gary


"Chrisso" wrote in message
oups.com...
Hi All

I am working on an automated backup scheme where my Excel
automatically makes a copy of itself every 7 days (although this is
configurable) in a seperate backup sub folder.

At the moment I record in the spreadsheet itself the date of the last
backup but this wont always work as sometimes a user will open the
spreadsheet in read-only - I still want to make the backup but I
cannot record the date of the backup in the spreadsheet.

So I think a better approach would be to look at the files in the
backup folder and find the one with the most recent date stamp - I can
then decide based on this date whether a new backup is required.

Is it possible in Excel VB to ask for the date stamp of all files in a
folder? Does anyone have some similar code?

Cheers and thanks in advance for any ideas,
Chrisso





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Is it possible to get a date stamp from an Excel file?

You could try

Sub test4()
newfiledate = FileDateTime("o:\mypath\myfile")

x = DateDiff("d", newfiledate, Now() + 8)
If x 7 Then
MsgBox ("Time for a backup") 'backup code here
End If

End Sub

Mike

"Chrisso" wrote:

Hi All

I am working on an automated backup scheme where my Excel
automatically makes a copy of itself every 7 days (although this is
configurable) in a seperate backup sub folder.

At the moment I record in the spreadsheet itself the date of the last
backup but this wont always work as sometimes a user will open the
spreadsheet in read-only - I still want to make the backup but I
cannot record the date of the backup in the spreadsheet.

So I think a better approach would be to look at the files in the
backup folder and find the one with the most recent date stamp - I can
then decide based on this date whether a new backup is required.

Is it possible in Excel VB to ask for the date stamp of all files in a
folder? Does anyone have some similar code?

Cheers and thanks in advance for any ideas,
Chrisso


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Is it possible to get a date stamp from an Excel file?

Just for completeness, this would work cross-platform too:

fPath = ThisWorkbook.Path & Application.PathSeparator

In article ,
"Gary Keramidas" <GKeramidasATmsn.com wrote:

sorry, saw a typo
fpath = fPath = ThisWorkbook.Path & "\"
should be
fPath = ThisWorkbook.Path & "\"

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
Opeing older files in Excel 2007 - file date-stamp amended Tim Childs[_4_] Excel Discussion (Misc queries) 0 June 29th 11 08:27 PM
Put date stamp on file name using VBA CAM Excel Programming 4 January 4th 07 02:40 PM
product date stamp file save Robert Loxley Excel Discussion (Misc queries) 12 November 13th 06 02:48 PM
Save file with time date stamp oberon.black[_91_] Excel Programming 1 September 22nd 05 01:13 AM
Getting a File Date & Time stamp James Excel Programming 5 February 8th 05 07:15 PM


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