Solved

VB6 Automation to different versions of Word

Posted on 2000-03-08
2
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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