Generating Interop RCWs for Word

E

Evan Stone

Hi,

I noticed that when I generate RCW DLLs from MSWORD9.OLB that I get two
DLLs: Word.dll and Office.dll, which is fine, but I was just musing on this
and wondering to myself where the typelib information for Office.dll was
coming from.

If I have Office 2003 on my system, and I'm trying to generate Office 2000
RCWs and am generating them with MSWORD9.OLB, will both of the resultant
DLLs a) be compatible with each other, and b) be compatible with Office
2000?

This is my first time trying this so I was just looking for a little more
information and reassurance... ;)

Thanks!

evan stone | software engineer
 
C

Cindy M -WordMVP-

Hi Evan,
I noticed that when I generate RCW DLLs from MSWORD9.OLB that I get two
DLLs: Word.dll and Office.dll, which is fine, but I was just musing on this
and wondering to myself where the typelib information for Office.dll was
coming from.

If I have Office 2003 on my system, and I'm trying to generate Office 2000
RCWs and am generating them with MSWORD9.OLB, will both of the resultant
DLLs a) be compatible with each other, and b) be compatible with Office
2000?
The word one should be... The other would, I think, be generated from
mso.dll. At least, that's the standard Office dll that is usually referenced
in a VBA project. But I have no idea whether this would be picked up
automatically for the same Office version. Could you try generating this,
first, then the Word one?

Best, certainly, would be to remove Office 2003 from the system while
developing for an older version...
This is my first time trying this so I was just looking for a little more
information and reassurance... ;)

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
E

Evan Stone

Hi Cindy,
The word one should be... The other would, I think, be generated from
mso.dll. At least, that's the standard Office dll that is usually referenced
in a VBA project. But I have no idea whether this would be picked up
automatically for the same Office version. Could you try generating this,
first, then the Word one?

I'll give this a shot and see what happens when I try to regenerate the
Word.dll.

The thing I'm running into presently is that I'd really like to be able to
specify the namespace of Office.dll (since by default it wants to create an
Office namespace, and I'd really rather have Interop.Office or something
along those lines). However, TLBIMP only seems to let me do that with the
immediate library I'm generating (in this case, Word.dll).

I'll try some more experimentation and see what happens, since we're
experiencing some funky behavior with the new set of Interop DLLs. :p

Thanks for your help!

evan stone | software engineer
 
P

Peter Gummer

Evan said:
The thing I'm running into presently is that I'd really like to be
able to specify the namespace of Office.dll (since by default it
wants to create an Office namespace, and I'd really rather have
Interop.Office or something along those lines). However, TLBIMP only
seems to let me do that with the immediate library I'm generating (in
this case, Word.dll).

Hi Evan,

This is a month late and so you may have already solved this, but
here's how I do it. It's for Excel, not Word, but hopefully you'll get
the idea:

tlbimp "C:\Program Files\Microsoft Office\Office\MSO97.DLL"
/out:Dme.Interop.Office97.dll /namespace:Microsoft.Office97.Core
/keycontainer:MyKey /sysarray

tlbimp "C:\Program Files\Common Files\Microsoft Shared\VBA\VBEEXT1.OLB"
/out:Dme.Interop.VBIDE97.dll /namespace:Microsoft.Vbe97.Interop
/keycontainer:MyKey /reference:Dme.Interop.Office97.dll /sysarray

tlbimp "C:\Program Files\Microsoft Office\Office\Excel8.OLB"
/out:Dme.Interop.Excel97.dll
/namespace:Microsoft.Office97.Interop.Excel /keycontainer:MyKey
/reference:Dme.Interop.Office97.dll /reference:Dme.Interop.VBIDE97.dll
/sysarray

The basic idea is that you tlbimp each library, starting with those
that have no dependencies (in this case Office), and then libraries
that have dependencies reference the ones you just built.

Note that I'm strong-naming the generated interp assemblies with MyKey.
This is optional, but you probably want to do so.

This technique of choosing your own namespace, rather than using
Microsoft's namespaces, is an approach I'm experimenting with. I'm
hoping to do this to avoid namespace conflicts if my application
references IAs for multiple versions of Office, in order to be
compatible with really old versions of 97 while still being able to
take advantage of features in new versions like 2003, if the user's
machine happens to have that newer version.

Unfortunately, I've just discovered that tlbimp /namespace doesn't work
on MSO.DLL for Office XP and 2003, because that particular type library
has a custom attribute specifying Microsoft.Office.Core. This is bad
for my plan, because if my application references the Office IAs for
both versions -- XP and 2003 -- then I'm likely to get conflicts
because both IAs have the same namespace.

The only way I can see around this problem with the Office XP and 2003
IAs is to edit the IAs manually:

1. Generate the IA with tlbimp.

2. Output IL for it with ildasm.

3. Edit the IL, replacing mentions of the Microsoft.Office.Core
namespace with some unambiguously version-specific namespace.

4. Regenerate the IA with ilasm.

I haven't tried this yet. I think it will work, but I was googling to
see if otheres had run into my problem when I discovered yours :)

-- Peter Gummer
 

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