WD: How to Access the Summary Info Dialog Box from a MacroLast reviewed: February 2, 1998Article ID: Q85168 |
1.x 2.x 6.00 6.00a 6.00c 7.00 7.0a | 6.00 6.0.1
WINDOWS | MACINTOSHkbusage kbmacro The information in this article applies to:
SUMMARYIn Microsoft Word for Windows, you can access the information in the Summary Info dialog box using the Microsoft WordBasic macro language and then post the information in a message box or insert the information into the active document.
MORE INFORMATIONTo obtain the value of any field in the Summary Info dialog box, use the GetCurValues statement to access the information, then assign a string variable (A$) to the value of the field desired. The following macro displays the number of words, characters, and pages in the active document:
Word 7.x, 6.x and 2.x
Sub MAIN FileSummaryInfo .Update Dim dlg As Dialog FileSummaryInfo GetCurValues dlg A$ = dlg.NumWords B$ = dlg.NumChars C$ = dlg.NumPages MsgBox "Words =" + A$ + Chr$(160) + "Characters = " + B$ \ + Chr$(160) + " Pages =" + C$ End SubIf you are using Word version 1.x for Windows, change the two occurrences of FileSummaryInfo to EditSummaryInfo. The .Update argument for the FileSummaryInfo command updates the summary information so that the number of words, number of characters, and number of pages are most accurate. Additionally, you can use a similar macro to insert the contents of fields within the Summary Info dialog box at the insertion position in the document. The following macro inserts the Title, Subject, and Author text as it appears in the Summary Info dialog box:
Word for Windows 6.0 and 2.0Sub MAIN FileSummaryInfo .Update Dim dlg As Dialog FileSummaryInfo GetCurValues dlg A$ = dlg.Title B$ = dlg.Subject C$ = dlg.Author Insert "Title:" + Chr$(160) + A$ InsertPara Insert "Subject:" + Chr$(160) + B$ InsertPara Insert "Author:" + Chr$(160) + C$ InsertPara End SubWord version 6.0 for Windows includes the following new parameters for the FileSummaryInfo statement:
.FileSize .NumParas .NumLinesIf you are using Word version 1.x for Windows, change the two occurrences of FileSummaryInfo to EditSummaryInfo. Note: "Using WordBasic" for Word version 2.x for Windows and the online documentation incorrectly list the following arguments as numbers instead of text variables:
.NumPages .NumWords .NumCharsNote: Microsoft provides macros "as is" without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. For information about how to do this in Word 97, please see the following article(s) in the Microsoft Knowledge Base:
ARTICLE-ID: Q158768 TITLE : Sample VB Code to Set, Retrieve Summary Information REFERENCES"Using WordBasic," by WexTech Systems and Microsoft, page 209 Kbcategory: kbusage kbmacro KBSubcategory: |
Additional reference words: winword2 1.0 1.1 1.1a 2.0a 1.00 1.10 1.10a 2.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |