Problem with Object Libraries

G

Greg Maxey

I am having a problem with the object library in Word2003.

Today I tried to dim a Balloon object

Dim Balloon as Balloon

I have used this line before, but today I got a error "Compile Error - User
Defined Type not defined.

I went to Tools>References, and noticed that I have two instances of
"Microsoft Word 11.0 Object Library" listed. One was checked as installed
and the other was not checked. I checked the second listing and the line
above worked normally.

The Object Library that isn't working is located at C:\Program
Files\Microsoft Office\Office11\MSWORD.OLB

The Object Library that is working is located at C:\Program Files\Common
Files\Microsoft Shared\Office11\M

I can't see the rest of the file because of the length limitation in the
display. If I look in that directory, there are several files that start
with "M" but none listed as MSWORD.OLB.

I can't remove the C:\Program Files\Microsoft Office\Office11\MSWORD.OLB
listing as it says it is in use.

I tried moving the listing that does work to the top of the list and
couldn't.

Question. How do I eliminate the double listing of Microsoft Word 11.0
Object Library and keep only the listing that is working correctly?

Thanks.
 
J

Jezebel

Hi Greg

First: you can get the full path and name of the library by examining the
references collection ...

? application.VBE.ActiveVBProject.References(1).FullPath

Second: I think you'll find if -- you look at your references list again --
that the missing library is not 'Word 11' but 'Office 11' -- since that's
where the Balloon object is defined.

So all that's happened here is that somehow the Office library has been
deselected for your active project. Reselect it and you should be fine.


Third: as a general principle, when you declare an object variable, ALWAYS
specify the library that defines the object ...

Dim pBalloon as Office.Balloon

The benefits are: 1) VBA tells you immediately if the library is missing,
and 2) you don't have a problem if the object is defined in more than one
library (such as Range, defined -- differently -- in both Word and Excel).


cheers
 
G

Greg Maxey

Jezebel,

Thanks for pointing out the tree while I was groping in the forests. You
are right of course. One is Office 11 and the other is Word 11. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top