VB.Net COM Add-in for MS Wors 2003 Beta problem

  • Thread starter Thread starter Jitender Singh Rawat
  • Start date Start date
J

Jitender Singh Rawat

Hi All,

I am currently working on a project, which involves
creating a COM Add-in using VB.Net, for MS Word 2003.

As usual, I am creating few custom menu buttons under the
File and Tool menus. These menu buttons are being created
in the OnStartupComplete event and removed in the
OnBeginShutdown event of the COM Add-in's connect class.
So, as per logic, everytime the Word starts, custom menu
buttons should get created, and on closure they should get
deleted.

Now my problem is that when I install the add-in and run
MS Word, i can see the custom created buttons. But when i
close the MS Word, the custom created buttons are not
getting deleted. I have checked this.... i.e. i un-
installed the COM-Add-in and run MS Word...the earlier
created custom menu buttons are still there! ...... and as
per logic, since Word is deleting them everytime COM Add-
in is closed, they should have not been there .....

I tested whether the menu buttons are being deleted in the
OnBeginShutdown....and they were...but some how...they
were being deleted temporarily.....and not permanentlly.

I wud like to mention here .. that I am using
CommandBarControl and CommandBar objects to create the
custom menu items. Also, I am using temporary=true
parameter while adding the commandbarcontrol.

Hence, i wud like to request u to kindly help or guide me
on this issue.

......its very urgent and I have already wasted lot of time
on it!

Thanxs in advance for ur kind help!!!

Jassi
 
Hi Jitender,

You don't mention whether you're setting a
CustomizationContext before creating/deleting the
CommandBarButtons. Note that the temporary argument does NOT
work for CommandBarButtonControls.

Word can save changes to commandbars in four different
"places", and if you don't specify, what it chooses as the
default when you create may not be the same default Word
decides to use to delete. So things won't get deleted. I see
this question, oh, maybe once a week when cruising the
Developer groups.
As usual, I am creating few custom menu buttons under the
File and Tool menus. These menu buttons are being created
in the OnStartupComplete event and removed in the
OnBeginShutdown event of the COM Add-in's connect class.
So, as per logic, everytime the Word starts, custom menu
buttons should get created, and on closure they should get
deleted.

Now my problem is that when I install the add-in and run
MS Word, i can see the custom created buttons. But when i
close the MS Word, the custom created buttons are not
getting deleted. I have checked this.... i.e. i un-
installed the COM-Add-in and run MS Word...the earlier
created custom menu buttons are still there! ...... and as
per logic, since Word is deleting them everytime COM Add-
in is closed, they should have not been there .....

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any follow
question or reply in the newsgroup and not by e-mail :-)
 
Hi Jitender,
But there is one small problem, at the time of menu addition in
OnStartupComplete... it is saving the custimization in Normal.Dot
file...but while menu deletion in OnBeginShutdown, things are not
getting saved implicitly..i.e. i have to give NormalTemplate.Save()
explicitly inorder to save the menu deletion in Normal.Dot.

Is it the way it works?
Put very simply, yes: this is the way it works.

More background: when you make changes to the NormalTemplate
(Normal.dot), Word won't ask or warn anyone about saving these until
the users quits Word. Then, depending on whether the option to prompt
to save changes to Normal.dot is activated (Tools/Options/Save), the
user may get a prompt to this effect. (Default if the option is not
activated is to save any changes.)

You run into a potential conflict with the user, here, if you try to
answer this question yourself at the END of the session, because the
user may well have added AutoText entries, macros, keyboardshortcuts
or their own menu customizations. Or may have been "playing" with
this kind of thing and be counting on NOT saving the changes. You
have no way of knowing. Unless, of course, you are fully controlling
this instance of Word (but then you could run into conflicts if the
user has a second instance running, because they will share
Normal.dot.)

Note that if you're certain no changes whatsoever should be saved to
the NormalTemplate, you can set NormalTemplate.Saved = True so that
Word ignores any changes; the prompt would not appear. (This does NOT
save changes, just changes what we used to call the "Dirty" flag.)

Due to this Word "idiosyncracy" with Normal.dot, it might be better
to supply your own Addin template, or create the document in which
the user will be working with your application from your own, special
template. This would also have the advantage that you wouldn't have
to repeatedly create and destroy toolbars, as they could be saved
directly in the template file...

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

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

Thanxs for ur reply.... I got ur point and i appreciate ur positive
response.

Though I might be bugging u and I am sorry for the same... but I have
one more query related to the topic...

I understand.. that in order to run a COM add-in in MS Word, which is
developed in VB.Net.... we need to have a certified custom shim
developed in VC++.Net... otherwise when the security is set at high our
add-in will not be loaded by the word coz u cant certify mscoree.dll
(though u can certify mscoree.dll, but there are other associated risks
involved with that)..

Now, I have gone though MS documentations, that u can develop a COM
Add-in shim in VC++.Net as well as in VB 6.0 ...I have
downloaded/accessed lot of material as well as source code for VC++.net
shim, but none for VB 6.0

Hence, do u have any idea as, what should I do to develop a COM Add-in
Shim in VB 6.0? If u have some sample code or site URL...kind advise me
of the same.

T&R!!!

Jassi
 
Back
Top