Solved

COM problems with MS Word

Posted on 2004-08-20
4
275 Views
Last Modified: 2010-04-23
I wanted to build a VB.NET class file which would replace words in a Word Document. Now, the unique thing about it is I guess it is COM, meaning I have to strong name it.

After many problems with trying to strong name the reference to Word.Interop, I found this documentation:

http://support.microsoft.com/?kbid=313666

I followed the VB.NET instructions to the tee, and it worked. I thought it was clear sailing from there...apparently not. The new reference I added was MyWord.dll which was the result of the documentation. I then declared it with the following:

Dim ThisApplication As MyWord.Application // to replace the regular Word.Application instance

Ok still going good...VS.NET recognizes all objects, methods, and properties of the regular MS Word Libs with MyWord.dll

Next, I take the project, put it onto a different computer, and register all the typelibs via regasm and then the assembly with gacutil.

Working good for like:

Dim my_text As String

Public Property mytext()
Get
Return my_text
End Get
Set(ByVal Value)
my_text = Value
End Set
End Property

But as soon as I call this function via COM from my other application:

Public Sub SearchReplace()
ThisApplication.Documents.Open("C:\test.doc")
End Sub

Everything stops with this error:

File or assembly name MyWord, or one of its dependencies, was not found.

Now I know that the Documents.Open() method exists, because my VS.NET sees it in object viewer. Could it be that I'm developing on 1 computer and then trying to make it work with another computer (I've registered and gac'ed on both computers).

Thanks in advance.
0
Comment
Question by:drakkarnoir
[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
  • 3
4 Comments
 
LVL 4

Accepted Solution

by:
Daniellus83 earned 500 total points
ID: 11855239
I had some trouble too,.. Are you sure all needed .dll are on the pther (non developing) system?

I used this commando's to register my assemblies:

gacutil /if myfile.dll
regasm myfile.dll

But in order to have these tools function fully I needed on the 'other' machine (.Net Framework v1.1 installed) the following files:

advapi32.dll
kernel32.dll
mscoree.dll
msvcr71.dll  <<
shlwapi.dll
user32.dll

Maybe it solves your problem... It is tricky to get this working, there are linkers on the market; they solve all these dependencies by adding all these used .net references (system.io ..etc) to your assembly: (http://www.remotesoft.com/linker/ is an example)

Hopes it helps you a bit... Daniël

-----
BTW: there are many ppl asking questions about strong naming. It is quite easy with the free tool Deadbolt.Net. You can find it here:

     https://secure.interscapeusa.com/Register/Downloads.aspx?Authenticated=True

> After install you create your own token (key) via tools>deadbolt.net>create... (vs.net2003).
> To digitally sign (strong name) your project, right-click on the Assembly.vb file in your project and choose "Digitally sign"

This tools saves you lot of time in the future signing your things


0
 
LVL 4

Expert Comment

by:Daniellus83
ID: 11855253
forgot: try resigning your assembly (with the tool) ...you never know....
0
 

Author Comment

by:drakkarnoir
ID: 11856190
I figured it out...it required me to register MyWord.dll via gacutil...

gacutil /i MyWord.dll

Now that message is gone, but I have another error:

Object reference not set to an instance of an object.

This happens when I reference any object or method.
0
 
LVL 4

Expert Comment

by:Daniellus83
ID: 11857927
Hello,..  I am happy the problem was solved easy...

The other thins "...Object reference not set to an instance of an object.."

Mostly this occurs when you do this:

   'Define it
   Dim i as Formtest

   'Use it (within a button_click or something...)
   Formtest.show

In some cases (classes..) you need to define (like this one)

dim i as Formtest = new formtest  'So the New() function inside gets called

If you define a var as string (Dim a as string) you don't use it...

So try this NEW thing... Else the object is still "Nothing" and then you get this error.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

728 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