Using OLE Automation to Get File Summary Info from Word 6 Doc

Last reviewed: May 22, 1997
Article ID: Q122239
The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic

  programming system for Windows, version 3.0
- Microsoft Word for Windows, version 6.0

SUMMARY

Visual Basic can communicate with Word version 6.0 via OLE Automation. For example, by using OLE Automation, you can access a Word document's file summary information from a Visual Basic application.

NOTE: The CurValues method discussed in the More Information section can be used with any Word dialog box such as ToolsOptionsView, DocumentStatistics, and so on.

MORE INFORMATION

The following steps show you how to create a Visual Basic application that retrieves file summary information from a Word version 6.0 document:

  1. Start a new project in Visual Basic. Form1 is created by default.

  2. Add a CommandButton (Command1) to Form1.

  3. Add the following code to the Command1_Click event of Form1:

          Sub Command1_Click ()
             Dim WordBasic As object
             Dim Wordvalues As object
             Set WordBasic = CreateObject("word.basic")
       
             ' In the next command, replace C:\GENERIC.DOC with  the name
       ' of the Word version 6.0 document for which you want to view the
             ' summary information.
             WordBasic.fileopen ("C:\GENERIC.DOC")
       
             Set Wordvalues = WordBasic.curvalues.FileSummaryInfo
             title$ = Wordvalues.title
             MsgBox "Title: " & title$
             subject$ = Wordvalues.subject
             MsgBox "Subject: " & subject$
             author$ = Wordvalues.author
             MsgBox "Author: " & author$
             filename$ = Wordvalues.filename
             MsgBox "FileName: " & filename$
             directory$ = Wordvalues.directory
             MsgBox "Directory: " & directory$
             Set Wordvalues = Nothing
             Set WordBasic = Nothing
          End Sub
    
    

  4. From the Run menu, choose Start (ALT, R, S) or press the F5 key to run the program.

  5. Click the CommandButton to see the document's summary information.


Keywords : IAPOLE kbinterop kbhowto
Technology : kbole


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: May 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.