Word Object Library Doesn't Reset from 10.0 to 9.0 - is there a fix / patch?

S

Shifty

Hi,
Is there a way to fix the fact that the Word Object Library reference
doesn't update properly? All other Office object library references
reset to the proper version.

I have a macro developed w/ Office 2K. It has references to Excel and
Word, among others. The library version is 9.0 for 2K. Some other
people open and edit the doc w/ Office XP (they don't open, run or
modify the macro however). Because they open it w/ Office XP, it
automatically sets the references to XP's version of the libraries
(which is 10.0).

When I then open the doc on 2000 again, all of the object libraries DO
reset back to 9.0...EXCEPT Word. Word doesn't reset to 9.0; it still
tries to look for 10.0 and shows up as missing. I'm obviously forced
to go into VB and update the reference to Word every time I want to
run the code. It looks like a bug to me...is there a patch that fixes
this?

Thanks!
-Kian
 
J

JGM

Hi Shifty,

I do not know if my idea will work for you, but anyway, here goes...

I use something like the following code when I want to set references
dynamically:

In this example I set the reference to Outlook XP before executing the code,
then I remove the reference after having executed the code (I did this
because the code was being called from an ActiveX command button, so if the
code was run twice, an error would be generated when trying to set the
reference a second time. You could just set the reference once in the
ThisDocument_Open and/or _New procedure... This way you would not have to
remove the reference in the code). Here I assume that Outlook is the same
version as Word (to make things easier), otherwise, you could check the
registry to make sure.

'_______________________________________
Select Case Application.Version
Case "10.0" 'XP
VBE.ActiveVBProject.References.AddFromFile "MSOUTL.OLB"

'Here call the macro/procedure you want to run

With VBE.ActiveVBProject.References
.Remove .Item("Outlook")
End With

Case "9.0" '2000
VBE.ActiveVBProject.References.AddFromFile "MSOUT9.OLB"
'writing this from memory, I am not sure I have the proper
'Outlook OLB file name for 2000...

'Here call the macro/procedure you want to run

With VBE.ActiveVBProject.References
.Remove .Item("Outlook")
End With

End Select
'_______________________________________

Of course, you could use late binding (not set references at all and dim all
application variables as Object, as in "Dim oWbook As Object" instead of
"Dim oWbook As Workbook" and avoid all this...); but I discovered that some
Outlook methods did not work with late binding.
Namely the "Outlook.MailItem.Attachments.Add" method. I could not for the
life of me get the add attachement work with late binding... I had to go
with early binding, thus the select case to make sure it was compatible with
various office versions...
 

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