HOWTO: Use OLE Automation to Get File Summary from Word 6 Doc
ID: Q122239
|
The information in this article applies to:
-
Microsoft Visual Basic Standard and Professional Editions for Windows, version 3.0
-
Microsoft Word for Windows, version 6.0
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:
- Start a new project in Visual Basic. Form1 is created by default.
- Add a CommandButton (Command1) to Form1.
- 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
- From the Run menu, choose Start (ALT, R, S) or press the F5 key to run the program.
- Click the CommandButton to see the document's summary information.
Additional query words:
Keywords : kbinterop kbAutomation kbVBp300 kbWord kbDSupport
Version : WINDOWS:3.0,6.0
Platform : WINDOWS
Issue type : kbhowto