VBA Excel add word 2003 or 2007 reference (11 or 12) based on word version

cynx
cynx used Ask the Experts™
on
my VBA code in Excel macro uses word reference.

However I want vba to auto refer word 11 or 12 object based on word version present on end users system, i.e. word 2003 or 2007.

how to achieve this ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2010
Commented:
If you have to support multiple versions of Word, then DON'T use a reference.  Use late binding instead.

Early binding, using a reference:

Dim wdApp As Word.Application
Dim wdDoc As Word.Document

Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Add

Open in new window


Late binding, no reference:

Dim wdApp As Object
Dim wdDoc As Object

Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.Documents.Add

Open in new window


If it's easier for you, do your development work using early binding, so you can use IntelliSense, but then switch to late binding for the copies you distribute.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial