Getting Words Version number

The following example demonstrates how to create a Word object to provide access to the objects in Word's object model. This procedure creates the object, displays the version number, closes the Word application, and then destroys the object, freeing up the memory that it used:

Sub GetWordVersion()

Dim WordApp As Object

Set WordApp = CreateObject("Word.Application") MsgBox WordApp.Version WordApp.Quit Set WordApp = Nothing End Sub

The Word object that's created in this procedure is invisible. If you want to see the object while it's being manipulated, set its Visible property to True, as follows:

WordApp.Visible = True

Most of the automation examples in this chapter use late binding as opposed to early binding. What's the difference? When you use early binding, you must establish a reference to a version-specific object library, using ToolsO References in the VBE. When you use late binding, setting that reference is not required. Both approaches have pros and cons.

0 0

Post a comment