Hi Scott:
Your wanting to apply a certain order to your selections makes the
process/code somewhat longer. I had to take your code and mix it with one
that I have for a hyperlink form in which I dump the name and path for each
record into a temporary table from which you could then use as a recordset
to manipulate- i.e. apply an order. The hyperlink form from which my code
came from can be found in
http://briefcase.yahoo.com/alborgmd, go to the "MS
Access Files" then download the "Use of Hyperlinks Form".
----------------------------------------------------------------------
With Application
.DisplayAlerts = False
.ScreenUpdating = Flase
With .filesearch
.NewSearch
.LookIn = Dir(Path & "\", vbNormal)
.FileName = *.doc
. SearchSubFolders = False
End With
.FileSearch
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("WordDocuments", dbOpenDynaset)
With rst
If .Execute() > 0 Then
MsgBox "There were " & .FoundFiles.Count & " file(s) found."
For i = 1 To .FoundFiles.Count
.AddNew
![Link] = .FoundFiles(i)
' the ![Link] entry will look like this: "C:\Office
Documents\AllportoAdmission.doc"
'![DocName] = Dir(rst![Link]) ' the
![DocName] will look like this: "AllportoAdmission.doc"-----> this line can
be removed
'![PathDate] = FileDateTime(rst![Link]) ' the
![PathDate] will look like this: "12/7/2001 8:17:46 AM" -----> this line can
be removed
.UPDATE
Next i
Else
MsgBox "There were no files found."
End If
End With
' now set the sort order that you wish
Set rst = dbs.OpenRecordset(Select WordDocuments.* from WordDocuments ORDER
BY WordDocuments.DocName; ", dbOpenDynaset)
' now begin attaching the files
With rst
For i = 1 To .Count
Application.Selection.InsertFile FileName:=![Link]
.InsertParagraphAfter
.InsertBreak Type:=wdSectionBreakNextPage
.Collapse Direction:=wdCollapseEnd
Next i
End With
The above code seems logical and like it should work for you. Please let me
know if you have any problems with it.
Regards,
AL
Scott Bass said:
Hi,
I received the following reply in microsoft.public.word.newusers. I was
hoping someone here could help me in modifying this macro:
http://vbaexpress.com/kb/getarticle.php?kb_id=214
I need to change the macro to display a File Selection dialog (which
supports wildcards), rather than the Folder Selection dialog.
Regards,
Scott