HOWTO: Use OLE Automation to Get File Summary from Word 6 Doc

ID: Q122239


The information in this article applies to:


SUMMARY

Visual Basic can communicate with Word version 6.0 through 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 TestWord As object
             Dim Wordvalues As object
             Set TestWord = 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.
             TestWord.fileopen ("C:\GENERIC.DOC")
    
             Set Wordvalues = TestWord.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 TestWord = 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.


Additional query words:


Keywords          : kbinterop kbAutomation kbVBp300 
Version           : WINDOWS:3.0,6.0
Platform          : WINDOWS 
Issue type        : 

Last Reviewed: July 26, 1999