Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Comparing date modified between two files

How can I find the date modified of an external file in Excel with a
macro? I am trying to merge only worksheets from files that are not
already in the current worksheet. Any ideas how to do this? thanks in
advance!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Comparing date modified between two files

s = "C:\Myfolder\MySheet.xls"
dt = filedatetime(s)

--
Regards,
Tom Ogilvy


"Koveras" wrote:

How can I find the date modified of an external file in Excel with a
macro? I am trying to merge only worksheets from files that are not
already in the current worksheet. Any ideas how to do this? thanks in
advance!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Comparing date modified between two files

How would I use this with a For Next Loop for all files in a folder?
Would I need to use BuiltinDocumentProperties("last save time") like
for example: If TargetWkbk.BuiltinDocumentProperties("last save time")
ActiveWorkbook.BuiltinDocumentProperties("last save time") Then and put the For Next loop in here? I dont have a lot of VB knowledge and this is confusing me. Thanks for your help



Tom Ogilvy wrote:
s = "C:\Myfolder\MySheet.xls"
dt = filedatetime(s)

--
Regards,
Tom Ogilvy


"Koveras" wrote:

How can I find the date modified of an external file in Excel with a
macro? I am trying to merge only worksheets from files that are not
already in the current worksheet. Any ideas how to do this? thanks in
advance!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Comparing date modified between two files

Sub ABC()
Dim rw as Long, sPath as String
Dim sName as string
rw = 2
sPath = "C:\Myfolder\"
sName = Dir(sPath & "*.xls")
do while sName < ""
cells(rw,1).Value = sName
cells(rw,2).Value = FileDateTime(sPath & sName)
rw = rw + 1
Loop
End Sub


just for illustration: from the immediate window:
? filedatetime("E:\Data\KZ081-Default Survey1.xls")
3/17/2002 5:51:20 PM


--
Regards,
Tom Ogilvy


"Koveras" wrote in message
ups.com...
How would I use this with a For Next Loop for all files in a folder?
Would I need to use BuiltinDocumentProperties("last save time") like
for example: If TargetWkbk.BuiltinDocumentProperties("last save time")
ActiveWorkbook.BuiltinDocumentProperties("last save time") Then and put
the For Next loop in here? I dont have a lot of VB knowledge and this is
confusing me. Thanks for your help



Tom Ogilvy wrote:
s = "C:\Myfolder\MySheet.xls"
dt = filedatetime(s)

--
Regards,
Tom Ogilvy


"Koveras" wrote:

How can I find the date modified of an external file in Excel with a
macro? I am trying to merge only worksheets from files that are not
already in the current worksheet. Any ideas how to do this? thanks in
advance!





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Comparing date modified between two files

This is excellent. I can definitely use this except it causes an
endless loop and only obtains the first file and writes it in all 65536
rows before crashing. What do I need to add to resolve this? Thanks
so much for the help!

Tom Ogilvy wrote:
Sub ABC()
Dim rw as Long, sPath as String
Dim sName as string
rw = 2
sPath = "C:\Myfolder\"
sName = Dir(sPath & "*.xls")
do while sName < ""
cells(rw,1).Value = sName
cells(rw,2).Value = FileDateTime(sPath & sName)
rw = rw + 1
Loop
End Sub


just for illustration: from the immediate window:
? filedatetime("E:\Data\KZ081-Default Survey1.xls")
3/17/2002 5:51:20 PM


--
Regards,
Tom Ogilvy


"Koveras" wrote in message
ups.com...
How would I use this with a For Next Loop for all files in a folder?
Would I need to use BuiltinDocumentProperties("last save time") like
for example: If TargetWkbk.BuiltinDocumentProperties("last save time")
ActiveWorkbook.BuiltinDocumentProperties("last save time") Then and put
the For Next loop in here? I dont have a lot of VB knowledge and this is
confusing me. Thanks for your help



Tom Ogilvy wrote:
s = "C:\Myfolder\MySheet.xls"
dt = filedatetime(s)

--
Regards,
Tom Ogilvy


"Koveras" wrote:

How can I find the date modified of an external file in Excel with a
macro? I am trying to merge only worksheets from files that are not
already in the current worksheet. Any ideas how to do this? thanks in
advance!






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Comparing date modified between two files

Left out a critical line of code:

Sub ABC()
Dim rw as Long, sPath as String
Dim sName as string
rw = 2
sPath = "C:\Myfolder\"
sName = Dir(sPath & "*.xls")
do while sName < ""
cells(rw,1).Value = sName
cells(rw,2).Value = FileDateTime(sPath & sName)
rw = rw + 1
sName = Dir()
Loop
End Sub

My apologies.

--
Regards,
Tom Ogilvy


"Koveras" wrote in message
oups.com...
This is excellent. I can definitely use this except it causes an
endless loop and only obtains the first file and writes it in all 65536
rows before crashing. What do I need to add to resolve this? Thanks
so much for the help!

Tom Ogilvy wrote:
Sub ABC()
Dim rw as Long, sPath as String
Dim sName as string
rw = 2
sPath = "C:\Myfolder\"
sName = Dir(sPath & "*.xls")
do while sName < ""
cells(rw,1).Value = sName
cells(rw,2).Value = FileDateTime(sPath & sName)
rw = rw + 1
Loop
End Sub


just for illustration: from the immediate window:
? filedatetime("E:\Data\KZ081-Default Survey1.xls")
3/17/2002 5:51:20 PM


--
Regards,
Tom Ogilvy


"Koveras" wrote in message
ups.com...
How would I use this with a For Next Loop for all files in a folder?
Would I need to use BuiltinDocumentProperties("last save time") like
for example: If TargetWkbk.BuiltinDocumentProperties("last save time")
ActiveWorkbook.BuiltinDocumentProperties("last save time") Then and
put
the For Next loop in here? I dont have a lot of VB knowledge and this
is
confusing me. Thanks for your help


Tom Ogilvy wrote:
s = "C:\Myfolder\MySheet.xls"
dt = filedatetime(s)

--
Regards,
Tom Ogilvy


"Koveras" wrote:

How can I find the date modified of an external file in Excel with a
macro? I am trying to merge only worksheets from files that are not
already in the current worksheet. Any ideas how to do this? thanks
in
advance!






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
Modified files Bob T Excel Discussion (Misc queries) 1 February 2nd 06 07:23 PM
modified date ceemo[_41_] Excel Programming 1 October 29th 05 06:20 PM
my excel files being modified by a virus mis_cakung Excel Discussion (Misc queries) 3 February 8th 05 12:17 PM
can it be modified to filter & list *.xls files only? Jack Excel Programming 3 September 14th 04 06:02 AM


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