Newbie Problem???

J

Jacques

Hello,

I created a simple VB6 Word add-in.
I have not written a single line of code,
and the program generates a run-time error.

Steps:
1) Created an add-in project.
2) Opened the designer of connect.dsr and set
Application to "Microsoft Word".
3) Added a reference in the VB project to "Microsoft
Word 9.0 Object Library".
4) Changed the Load behavior to "Start Up"
5) Changed the Debugging tab to start program
"c:\program files\..\Winword.exe
6) Set a break point in the
AddinInstance_OnConnection(..) method.
7) Clicked F5 to Start Debugging

The program immediatly generates a run-time error: "Type
Mismatch"


Option Explicit

Public VBInstance As VBIDE.VBE

[...]


Private Sub AddinInstance_OnConnection(
ByVal Application As Object,
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode,
ByVal AddInInst As Object,
custom() As Variant)

On Error GoTo error_handler

'save the vb instance
Set VBInstance = Application 'Generates a run-time
'error: "Type mismatch"

'The value of Application is "Microsoft Word"

...

End Sub


Any Ideas?


TIA,
Jacques
 
T

Thomas Winter

Jacques said:
Hello,

I created a simple VB6 Word add-in.
I have not written a single line of code,
and the program generates a run-time error.

Steps:
1) Created an add-in project.
2) Opened the designer of connect.dsr and set
Application to "Microsoft Word".
3) Added a reference in the VB project to "Microsoft
Word 9.0 Object Library".
4) Changed the Load behavior to "Start Up"
5) Changed the Debugging tab to start program
"c:\program files\..\Winword.exe
6) Set a break point in the
AddinInstance_OnConnection(..) method.
7) Clicked F5 to Start Debugging

The program immediatly generates a run-time error: "Type
Mismatch"


Option Explicit

Public VBInstance As VBIDE.VBE

[...]


Private Sub AddinInstance_OnConnection(
ByVal Application As Object,
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode,
ByVal AddInInst As Object,
custom() As Variant)

On Error GoTo error_handler

'save the vb instance
Set VBInstance = Application 'Generates a run-time
'error: "Type mismatch"

'The value of Application is "Microsoft Word"

..

End Sub


Any Ideas?


TIA,
Jacques

What is being passed to the OnConnection() event as the Application
parameter is WORD's Application object. It is NOT an instance of the VB or
anything like that. You need to have a public variable of type
Word.Application and save the Application parameter into that.

-Tom
 

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