Debuggin word add-in

D

durrenm

I've seen this problem posted in a few places but never any solution.

I cannot seem to debug my word addin. The add-in runs fine when
installed as a normal add-in but does not work when run via the
debugger.

Strange because it worked earlier this week.

I even created a generic basic add-in using the add-in wizard and added
one line of code to the on-connection event

msgbox("on connection", msgboxstyle.okonly)

But still no success.

I've gone through this a few times now. First everthing works fine.
Then, perhaps after writing some broken code, I can't get the debugger
to kick in on the add-in.

Any suggestions? FYI I've tried deleting all registry entries to my
add-in then rebuilding too...

Thanks in advance,
Mark
 
B

Bernd Schend

Hi Mark,

I am using VB.NET and implemented the solution below.
It works fine. Hope you can use it.

"WordWrapper" is a class wrapping a Word application.

Regards
Bernd



Public Sub TestAddin()

Dim MSWord As Word.Application

Try
MSWord = DirectCast(GetObject(, "Word.Application"), _
Word.Application)
Catch
MSWord = DirectCast(CreateObject("Word.Application"), _
Word.Application)
MSWord.Visible = True
End Try

If Not MSWord Is Nothing Then
Dim WordAppl As New WordWrapper(MSWord)
MSWord.Visible = True
MSWord.WindowState = Word.WdWindowState.wdWindowStateNormal
Console.WriteLine("Word started...")
End If

Dim T As New Threading.Thread(AddressOf Me.WaitForWordToTerminate)
T.Name = "XYZ"
T.ApartmentState = Threading.ApartmentState.STA
T.Start()

T.Join()

End Sub

Private Sub WaitForWordToTerminate()
Dim O As Object = GetObject(, "Word.Application")
While Not O Is Nothing
Threading.Thread.Sleep(5000)
Try
O = GetObject(, "Word.Application")
Catch
O = Nothing
End Try
End While

End Sub
 
D

durrenm

Bernd

How do I use it? Do I put your "addin" code in my connect class or do I
create a new class?

Thanks,
Mark
 
D

durrenm

It's working again, here are the steps I think made all the difference:

in winword.exe.config

It appeared that both .net 1 and .net 1.1 were "supported"
<supportedRuntime version"v1.1.4322"/> was followed by
<supportedRuntime version"v1.0.nnnn"/> (Not actually nnnn but some
number I don't recall)

I deleted the reference to .net 1.0


Also, I removed .net framework 2.0 (I found a comment somewhere that
suggested that vsnet2002 had problems with .net 2.

So for now, all appears to be working. I'll keep my fingers crossed...

Mark
 
D

durrenm

I spoke too soon... stopped working after one successful run into the
debugger, I, once again, can nolonger debug my add-in.

Sigh.

Anybody following this thread or am I just broadcasting into space?

Mark
 
B

Bernd Schend

Bernd

How do I use it? Do I put your "addin" code in my connect class or do I
create a new class?

Thanks,
Mark
Hi Mark,

you need to create a new class representing the Word wrapper. I called
it "WordAplication". When created, it adds a menu to Word's menubar,
for instance. It also reacts to Word's events.

Good luck
Bernd


Public Class WordApplication

Private WithEvents MyWordApplication As Word.Application

....

Private Sub MyWordApplication_DocumentChange() _
Handles MyWordApplication.DocumentChange

....


end sub


end class
 

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