ID: Q71995
The information in this article applies to:
The WordBasic FileName$() function returns the document file name and path. The following macro inserts the document name and path into your document window.
Sub MAIN
a$=FileName$()
Insert a$
End Sub
However, if the insertion point is positioned within a header or
footer, the document file name and path is not inserted. This occurs
because the header and footers in Word for Windows are treated as
separate windows from the document window. As a result, the FileName$()
function does not return the name of the document.
The following macros can be used as alternatives to using the FileName$() function. To determine the document name and directory, the macros access the summary information dialog box and extract the filename and directory information. Word for Windows adds the directory and filename together with a backslash between them with the following macro line:
Insert A$ + "\" + B$
The path and filename (C:\WINWORD\README.DOC) are inserted at the
position of the insertion point.
The following macro inserts the document file name and path into the document header.
Sub Main
ViewNormal
FileSummaryInfo .Update
Dim dlg As Dialog FileSummaryInfo
GetCurValues dlg
A$ = dlg.Directory
B$ = dlg.FileName
ViewHeaderFooter 'open document header
Insert A$ + "\" + B$
ClosePane
End Sub
In this macro, change the line "ViewHeaderFooter" to "ViewHeaderFooter
.type=1" to insert the information into the footer.
Position the insertion point in the header or footer and run the following macro.
Sub MAIN
EditSummaryInfo .Update
Dim dlg As Dialog EditSummaryInfo
GetCurValues dlg
A$ = dlg.Directory
B$ = dlg.FileName
Insert A$ + "\" + B$
End Sub
The document name and path are inserted at the insertion point. To
automate the process entirely, use the EditHeaderFooter command to open
the header or footer pane.
EditHeaderFooter 'header
EditHeaderFooter 1 'footer
Microsoft has confirmed this to be a problem in Word for Windows, versions 1.x and 2.x. This problem was corrected in Word for Windows, version 6.0.
"Microsoft Word for Windows User's Reference," page 96 "Microsoft Word for Windows Technical Reference," page 46 "Microsoft Word for Windows and OS/2 Technical Reference," pages 163-164
Kbcategory: kbusage kbmacro KBSubcategory: Additional query words: 1.1a 1.x 2.0 winword2 winword directory edit summary full complete location winword macword
Version : 1.x 2.x
Platform : WINDOWS
Last Reviewed: July 30, 1997