Discussion:
VB6 COM add-in for MS Word 2000
(too old to reply)
Nam
2006-05-29 17:25:02 UTC
Permalink
I want to create a COM Add-In for MS Word 2000 using VB6 that should perform
the following:

1. Add in has a VB form that contains a VB6 toolbar control etc.

2. When user clicks on a commandButton on MS Word toolbar, the VB6 form pops
up. The form is docked to the border of the Word document window during the
editing of the document.

3. When a user clicks on a VB6 toolbar button, a certain text gets typed in
on the Word document.

I can take care of item 3 above. I have read some MSDN articles like the
following, but I am still unclear on item 1 and 2 above:
http://support.microsoft.com/kb/q238228
http://www.microsoft.com/technet/prodtechnol/office/office2000/proddocs/opg/part2/ch11.mspx

NOTE: My actual task is much more complex, so I do not want to use Word
templates as add-in.

Thank you in advance,
Nam
Nam
2006-05-29 21:15:01 UTC
Permalink
I was able to create a COM Add-In for MS Word by following the following
article
http://support.microsoft.com/kb/q238228/

The only change that I made in the code for above article was that in the
Designer window, I selected the application to be MS Word 9.0

I ENCOUNTERED THE FOLLOWING PROBLEM: Whenever I open the MS Word, it creates
an additional copy of the command button on the toolbar. First time I open
the MS Word, it creates one “My CuSstom Button” on the toolbar, second time I
open MS Word, it creates another “My CuSstom Button” on the toolbar and so on.

The same example for Excel works fine and it does not create a new “My
CuSstom Button” every time I open Excel.

What is I need to do to resolve the above issue for MS Word?

Thanks,
Nam
Post by Nam
I want to create a COM Add-In for MS Word 2000 using VB6 that should perform
1. Add in has a VB form that contains a VB6 toolbar control etc.
2. When user clicks on a commandButton on MS Word toolbar, the VB6 form pops
up. The form is docked to the border of the Word document window during the
editing of the document.
3. When a user clicks on a VB6 toolbar button, a certain text gets typed in
on the Word document.
I can take care of item 3 above. I have read some MSDN articles like the
http://support.microsoft.com/kb/q238228/
http://www.microsoft.com/technet/prodtechnol/office/office2000/proddocs/opg/part2/ch11.mspx
NOTE: My actual task is much more complex, so I do not want to use Word
templates as add-in.
Thank you in advance,
Nam
Ignoramus
2006-05-30 08:04:10 UTC
Permalink
Hi,

I had a similar problem when I tried to add command buttons on
connection event and remove the buttons on disconnection event of my
COM addin.

The reason of button multiplication is that when you add your buttons,
you modify the Normal.dot (which is evil btw) and when you quit Word,
Normal.dot gets saved BEFORE the COM add-in disconnection event is
fired, so that removing the buttons has no persistent effect.

My solution was to switch from creating buttons in COM addin at runtime
to providing an additional macro-free DOT add-in which contains all the
buttons created at design time, and the COM addin only connects its
handlers to the buttons. In this manner you also resolve the problem of
modifying user's Normal.dot.

BTW you will find a lot of references to this issue in this newsgroup
if you search.
Nick Hebb
2006-06-24 17:55:36 UTC
Permalink
The code given in that article is a bad example. You shouldn't add a
button to the Standard command bar. You should create your own command
bar, set it as temporary (which is one of the parameters to
Application.CommandBars.Add()), then add your cusom button to the
custom toolbar.

To do it right is more than just a few lines of code, so it's more than
I'm willing to post here. I would recommend getting a copy of
Professional Excel Development by Bullen, Bovey, and Green. I realize
that you're doing a Word add-in, but the CommandBars are MS Office
objects and behave the same for all Office COM Add-ins (except for a
few quirks w/ Outlook). So the code samples in Chapter 21 are
invaluable to any Office COM development.

HTH,

Nick Hebb
BreezeTree Software

Loading...