Solved

VB6 Automation to different versions of Word

Posted on 2000-03-08
2
192 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 70

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

830 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