fumei
Mon Jun 30 12:42:40 PDT 2008
Curses. For every instance where I have used FoundFile in the posts...it
must be FoundFiles.
FoundFile is invalid.
fumei wrote:
>Just because I have a bugbear about explicitness...
>
> For i = 1 To .FoundFiles.Count
> ' this sends each file to the DoStuff procedure
> Call DoStuff(.FoundFile(i))
> Next i
>
>My comment is technically incorrect....i.e. wrong.
>
>It does NOT send each file to the DoStuff procedure. It sends a STRING -
>which is the path and name of each FoundFile - to the DoStuff procedure.
>
>You could of course actually send the file, although I am not sure there is
>an advantage.
>
>Sub yadda()
>Dim fs As FileSearch
>Dim i As Long
>Dim ThatDoc As Document
>Set fs = Application.FileSearch
>With fs
> .LookIn = "C:\zzz"
> .FileName = "*.doc*"
> If .Execute(SortBy:=msoSortByFileName, _
> SortOrder:=msoSortOrderAscending) > 0 Then
> For i = 1 To .FoundFiles.Count
> Set ThatDoc = Application.Open Filename:= .FoundFile(i)
> ' this really does sends each file to the DoStuff procedure
> Call DoStuff(ThatDoc)
>
> ' note that the ThatDoc object should be destroyed HERE
> ' in the procedure that created it
> Set ThatDoc = Nothing
> Next i
> Else
> MsgBox "There were no files found."
> End If
>End With
>End Sub
>
>Sub DoStuff (Incoming As Document)
>
> With Incoming
> ' action the opened file
> ' blah blah
>
> ' then Close it
> .Close wdSaveChanges
> End With
>
> ' control is passed back to originating Sub
>End Sub
>
>>You are using FileSearch. Did you it look up in Help?
>>
>[quoted text clipped - 120 lines]
>>>
>>>Carlos
--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200806/1