Solved

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

Posted on 2011-09-02
1
429 Views
Last Modified: 2012-05-12
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 ?
0
Comment
Question by:cynx
1 Comment
 
LVL 92

Accepted Solution

by:
Patrick Matthews earned 500 total points
Comment Utility
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.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now