Macro to Generate Report of Files Found with FindFile Command
ID: Q96566
|
The information in this article applies to:
-
Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
-
Microsoft Word for Windows 95, version 7.0
SUMMARY
The Microsoft Word for Windows macro included in this article generates a
report of the file names found in the Find File dialog box. Use this macro
to return a list of the file names that match your Find File search
parameters.
MORE INFORMATION
The macro displays the standard Find File dialog box; however, after
you choose the Close button to exit the File Find dialog box, the
macro asks the following question:
Shall I insert a list of files found in a new document?
If you choose the Yes button, the macro creates a new Word for Windows
document and inserts the file names of all files found.
CREATING THE MACRO
Use the steps appropriate for your version of Word.
Word 2.x
- On the File menu, click Template.
- Under "Store New Glossaries and Macros As," select the Global
option button, then choose the OK button.
NOTE: This step causes the new FileFind command to be stored in
Normal.dot. If you want the new command to be template based, select
the With Document Template option button instead of Global.
- On the Tools menu, click Macro.
- Under Show, select the Commands button. In the Macro Name
box, select FileFind, then choose the Edit button.
- Delete the text in the macro-editing window and type the following
macro text:
Sub MAIN
Dim dlg As FileFind
GetCurValues dlg
Dialog dlg
NumFiles = CountFoundFiles()
If Numfiles > 0 Then
If MsgBox("Shall I insert a list of files found in a new document?" \
,292) = 0 Then
Goto done
End If
Else
Goto done ' no files to report
End If
FileNew
For x = 1 To Numfiles
Insert FoundFileName$(x)
InsertPara
Next x
done: '<-- Note: Labels MUST be left aligned
End Sub
- On the File menu, click Close. Choose the Yes button when
prompted to save changes to the macro.
- On the File menu, click Save All, and when prompted, choose to
save global glossary and command changes.
Word 6.x, 7.0, and 7.0a
- On the Tools menu, click Macro.
- In the Macro Name box, type a name like FileList, then choose the
Edit button (Word 6.x) or the Create button (Word 7.x).
- Type the following macro text:
Sub MAIN
Dim dlg As FileFind
GetCurValues dlg
Dialog dlg
NumFiles = CountFoundFiles()
If Numfiles > 0 Then
If MsgBox("Shall I insert a list of files found in a new document?" \
,292) = 0 Then
Goto done
End If
Else
Goto done ' no files to report
End If
FileNew
For x = 1 To Numfiles
Insert FoundFileName$(x)
InsertPara
Next x
done: '<-- Note: the colon and labels MUST be left aligned!!
End Sub
- On the File menu, click Close. Choose the Yes button when
prompted to save changes to the macro.
- On the File menu, click Save All, and if prompted choose yes
to save changes to the Normal template.
This macro causes the Print and Open buttons to become unavailable in the
Find File dialog box.
WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN
RISK. Microsoft provides this macro code "as is" without warranty of any
kind, either express or implied, including but not limited to the implied
warranties of merchantability and/or fitness for a particular purpose.
REFERENCES
"Microsoft Word for Windows User's Guide," version 2.0, pages 765,
784-786
Additional query words:
winword2 2.0 word7 word6 7.0 word95 winword printout 6.0
Keywords : kbmacro kbusage
Version : WINDOWS:2.0,2.0a,2.0a-CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0
Platform : WINDOWS
Issue type :
|