PC Review


Reply
Thread Tools Rate Thread

Comparing date modified between two files

 
 
Koveras
Guest
Posts: n/a
 
      4th Oct 2006
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 With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      4th Oct 2006
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 With Quote
 
Koveras
Guest
Posts: n/a
 
      4th Oct 2006
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 With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      5th Oct 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 With Quote
 
Koveras
Guest
Posts: n/a
 
      5th Oct 2006
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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 With Quote
 
Tom Ogilvy
Guest
Posts: n/a
 
      6th Oct 2006
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting files by date modified Katharine Windows Vista File Management 5 11th Apr 2009 05:10 AM
help - unreadable files with same modified date =?Utf-8?B?UGFsbWJzZWE=?= Windows XP General 2 31st Jul 2007 03:38 AM
How do I copy new files and modified files having new time/date? Don J Windows XP General 2 15th Apr 2007 06:12 AM
Date Modified not changing on files =?Utf-8?B?Y2hlc2hpcmUxOTE=?= Windows XP Networking 0 13th Jan 2005 03:31 PM
Last-Modified date of copied files Bill Shapiro Windows XP General 0 13th Jul 2003 04:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:11 AM.