how to reference a lower version of Microsoft Word

I have a very simple appliction, but it requires a reference to Microsoft Word. Right now my development PC has Word 2003 loaded and so that is the only reference I am provided with. Some of my end users will only have Word 2000 or Word 2002. How can I make a reference to a lower version of Microsoft word in my application so that when it is compiled and sent out, users with prior versions of Microsoft Word don't wind up with error messages?
LVL 6
Mach1proAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
It may not matter, but you can always use late binding.

Remove the reference to the Word library.

Modify the code to decalre all the word objects as Object (not Application, Document, Range, Table, etc) and use GetObject and/or CreateObject to set the Application. The code to set and manipulate the other objects should still work the same.

'Early Binding
    Dim wdApp As Word.Application
    Dim wdDoc As Word.Document
    Dim objTable As Word.Table
    
    Set wdApp = New Word.Application
    wdApp.Visible = True
    Set wdDoc = wdApp.Documents.Add
    Set objTable = wdDoc.Tables.Add(wdDoc.Range(0, 0), 4, 2)
 
'Late Binding
    Dim wdApp As Object
    Dim wdDoc As Object
    Dim objTable Object
    
    Set wdApp = CreateObject("Word.Application")
    wdApp.Visible = True
    Set wdDoc = wdApp.Documents.Add
    Set objTable = wdDoc.Tables.Add(wdDoc.Range(0, 0), 4, 2)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hesCommented:
What Graham has suggested will work as long as you code for the lowest version of Word you are expecting. If you add a "feature" that Word 2003 has but the lower versions do not ,you will get an error.
0
GrahamSkanRetiredCommented:
Yes. It is always best to develop and test in the earliest environment that you have to support.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.