Excel searches through the selected libraries to find the reference for the object type If the type is found in more than one library the first reference is selectedYou can influence which library is chosen by changing the priority of the reference in the

Sub WordEarlyBinding()

Dim wdApp As Word.Application

Dim wdDoc As Document

Set wdApp = New Word.Application

Set wdDoc = wdApp.Documents.Open(ThisWorkbook.Path & _

"\Chapter 16 - Automating Word.doc") wdApp.Visible = True Set wdApp = Nothing Set wdDoc = Nothing End Sub

This example opens an existing Word document from Excel. The declared variables, wdApp and wdDoc, are of Word object types. wdApp is used to create a reference to the Word Application in the same way the Application object is used in Excel. New Word.Application is used to create a new instance of Word.

0 0

Post a comment