Solved

VB6 Automation to different versions of Word

Posted on 2000-03-08
2
189 Views
Last Modified: 2010-05-18
My VB6 application references the Word 8.0 object library and automates Word97 OK

The application also needs to run on computers which have Word 95 installed but currently it fails with an err 429.

How can I (is it possible?) to make an application reference which ever version of Word the user has installed? (Including Word 2000 which I do not have).
0
Comment
Question by:midexpro
2 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 2596780
Use Late binding instead of early binding!

To use late binding, you don't reference Word, you declare your Word object variable as Object (Dim objWord As Object) and use the CreateObject to instantiate Word (Set objWord = CreateObject("Word.Application"))

This way, you will use whatever version the PC have installed.
0
 
LVL 32

Accepted Solution

by:
bhess1 earned 50 total points
ID: 2596846
If you are using the Project/References to refer to the word 8.0 library, I'm afraid that you're out of luck.  You'll have to use a different method to work with multiple versions of Word.

Something like this can be used:

Global wdBasic As Object

Set wdBasic = CreateObject("Word.Basic")
wdBasic.FileOpen TMPLTDIR & "WINWORD\" & N & ".DOC"

This references the generic Word Basic object for you, and opens a document.  It will use the latest version of Word that the user has.

Note that you may need to check for the version of Word that the user has:

If Val(wdBasic.AppInfo(2)) >= 8 Then
  'Winword version
   wdBasic.FileExit   'doesnt work w/
             Word 6 (pre Office 97 ver.)
End If

This will also allow you to inform the user if there are features they will be unable to use, due to version limitations.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 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

18 Experts available now in Live!

Get 1:1 Help Now