Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Late binding of MSWORD object in VB6

Status
Not open for further replies.

njitter

Technical User
Sep 4, 2001
122
0
0
US
Hello,

i'm using a VB6 program developed by an external company. It works fine in our company. We are using MS Word 2002.

We want to deploy this software at another site. Unfortunately they are using MS Word 2003.

The compiled program is not working because the reference to MSWORD 10 library is missing.

I read something about Late binding to solve this. I did not get the examples provided by Microsoft.
The library is currently called like this:

Set WordDoc = CreateObject("Word.Application")

What do i need to change to use late binding??

Regards,

Njit

---
It's never too late to do the Right thing
 
Remove all references to Word objects on the references .

-
do use
Set WordDoc = CreateObject("Word.Application")
instead of
set worddoc = word.application.

Dont DIM any word object directly.
e.g dim newdoc as word.document.

use instead
dim newdoc as object


Main thing agains late binding is that you CAN NOT use the constants that are added automatically when you reference the library.

e.g. no more
Dim aa As Word.Document
aa.Bookmarks.DefaultSorting = wdSortByLocation

You will need to define wdSortByLocation by yourself if you wish to use it. Same applies to all other constants.

Many people use early binding at development, and then change to late binding, as using early lets you avail from all the auto completion each object/property/method has.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
How do you know, Bob? Apart from the fact that it almost certainly has to be ...
 
Ah, semantics. I was reading the question as "should one Dim WordDoc as Object?" rather than taking it in its more literal sense. No doubt Sheco is entirely aware that it should be dimmed as Object.
 
I fell foul of semantics as well. 'has to be' should read 'ought to be' [blush]

 
Well, yes, no doubt there are lots of unnecessary variants running around in late bound code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top