Solved

VB6 Automation to different versions of Word

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

863 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

24 Experts available now in Live!

Get 1:1 Help Now