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?
 
GrahamSkanConnect With a Mentor RetiredCommented:
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
 
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
All Courses

From novice to tech pro — start learning today.