word addin commandbar not called vb.net word 2003

K

kedar v

i have created a word addin in .net 2003. i am using word 2003
but following line gives error whenever i open an existing document:
CType(applicationObject, Word.Application).CustomizationContext =
CType(applicationObject, Word.Application).ActiveDocument
the error is that there is no open word document.
my problem in word addin can also be described as:
http://www.thescripts.com/forum/thread373043.html
i think its all about getting inspector and adding commandbar items in its
event... but i am not able to do that...
can anyone please post a code to handle that problem and make it work.

well , can featured expert or pageEditor can help here??!!!
in commandbar button loads in one word app. bt not in 2nd instance of word
document

i'm calling this function from OnStartupComplete..
well i;ve tried an another way, used WindowActivate event of word object to
add commandbar .. well it does work in case of opening existing document but
as WindowActivate event fires several times it makes my addin slower..
hence i've set the object to nothing .. which causes event to be fired once.
You might thought, so whats the problem..??!! well, as soon as i set object
as nothing.. it stops futher firing generating NewDocument event or anything
else..
So .. no more addin loaded in new Document generated by clicking on new.
HELP... it getting my mind hyper...

My prob. starts with a looong histry..
First of all i;ve created word addin.. which when removed leaves the trace
behind. I mean my_button(added in File Menu) is left there on word document.
I solved this NOTORIOUS problem using Normal.DOT way, like this
[CType(applicationObject, Word.Application).ActiveDocument.Saved = True]
and it get solved.

now, the problem occurs whenever i open and existing document.
Reason: As there is no ActiveDocument, the code above gives me an error

To solve this problem, i've used word document's WindowActivate event to add
my button to file menu, by following way..
OnStartupcomplete, i assigned application-Object to objW, like this,
wObj = CType(applicationObject, Word.Application).Application

and then add my own menu button to File-Menubar of word, like this:
[applicationObject.CommandBars.item("File").Controls.Add(MsoControlType.msoControlButton, 1, "", 6, True)]
well, i do check of if button already exists or not.

Now Problem arouse, as WindowActivate Event fires many times, that makes my
pgm sick. So in solution of that, i have set objW = nothing
which causes No more WindowActivate event(Only once) and still code runs fine.

Setting objW = nothing raises one more error:
Now as i create a new Document from File>New, the addins button not loaded
in it as no event fired !
I'm trying all different events for this and different approaches for this,
but all invain.. of no use or just not working..
Your replies gives me new hope to work on for the solution.. thanks for ur
replies... if u find any line confusing .. do ask .. Thank you
 
C

Cindy M.

Hi kedar,
i have created a word addin in .net 2003. i am using word 2003
but following line gives error whenever i open an existing document:
CType(applicationObject, Word.Application).CustomizationContext =
CType(applicationObject, Word.Application).ActiveDocument
the error is that there is no open word document.
my problem in word addin can also be described as:
http://www.thescripts.com/forum/thread373043.html
i think its all about getting inspector and adding commandbar items in its
event... but i am not able to do that...
can anyone please post a code to handle that problem and make it work.

well , can featured expert or pageEditor can help here??!!!
in commandbar button loads in one word app. bt not in 2nd instance of word
document
I'm afraid your problem isn't quite clear. You've created a COM Add-in using
VB.NET 1.1, targeting Word 2003?

What is triggering the code that's producing the error? Is this a document-
or application-level event? A commandBarButton? Something else?

What are you trying to achieve? The problem in the link you posted is that
the person wants a button to be available for all Word documents. Is that
what you need?

Word doesn't have the concept of inspectors, that belongs to Outlook.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

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

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