Microsoft KB Archive/85168

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 18:16, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

WD: How to Access the Summary Info Dialog Box from a Macro

Q85168

1.x 2.x 6.00 6.00a 6.00c 7.00 7.0a | 6.00 6.0.1 WINDOWS | MACINTOSH kbusage kbmacro



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, versions 7.0, 7.0a
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1





SUMMARY

In 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 INFORMATION

To 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 Sub 

If 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.0

Sub 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 Sub 

Word version 6.0 for Windows includes the following new parameters for the FileSummaryInfo statement:

.FileSize

.NumParas

.NumLines

If 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

.NumChars

Note: 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:

Q158768 Sample VB Code to Set, Retrieve Summary Information



REFERENCES

"Using WordBasic," by WexTech Systems and Microsoft, page 209

Kbcategory: kbusage kbmacro

Additional query words: winword2 1.0 1.1 1.1a 1.00 1.10 1.10a word95 word7 word6 winword 2.00a msgbox author title subject insert macword 6.0.1 7.00a

Keywords : kbmacro kbmacroexample winword ntword macword
Issue type :
Technology : kbHWMAC kbOSMAC kbWordSearch kbWordMacSearch kbWord700Search kbZNotKeyword2 kbWord600Mac kbWord601Mac kbWord600 kbWord600a kbWord600c kbWord200 kbWord200a kbWord200b kbWord200c kbWord700 kbWord700a


Last Reviewed: November 5, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.