how to reference/open last file modified

M

muyBN

In the following code, I want to search for and open the most recent file
modified, but don't know how to write that particular line. Assistance will
be appreciated. Thanks.

strPath = [path name]
strFirstFile = ActiveDocument.name
With Selection
With Application.FileSearch
.NewSearch
.LookIn = strPath
.SearchSubFolders = False
.FileName = "*.csv"
.Execute (msoSortByLastModified)
intFiles = .FoundFiles.count
If .Execute(msoSortByLastModified, msoSortOrderAscending) > 0 Then
strFile = [last modifed file]
End If
End With
End With
Documents.Open (strPath & "\" & strFile), AddToRecentFiles:=True,
Format:=11
 
P

Perry

Look at yr previous posting in this group.
--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
 
M

muyBN

Sorry, it was late and I thought I had accidentally closed the first question
(since there's a lag in questions actually being posted).

--
Bryan


Perry said:
Look at yr previous posting in this group.
--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE



muyBN said:
In the following code, I want to search for and open the most recent file
modified, but don't know how to write that particular line. Assistance
will
be appreciated. Thanks.

strPath = [path name]
strFirstFile = ActiveDocument.name
With Selection
With Application.FileSearch
.NewSearch
.LookIn = strPath
.SearchSubFolders = False
.FileName = "*.csv"
.Execute (msoSortByLastModified)
intFiles = .FoundFiles.count
If .Execute(msoSortByLastModified, msoSortOrderAscending) > 0
Then
strFile = [last modifed file]
End If
End With
End With
Documents.Open (strPath & "\" & strFile), AddToRecentFiles:=True,
Format:=11
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top