Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Tue, 14 Aug 2007 16:12:19 -0400,    group: microsoft.public.word.vba.addins        back       


CommandBar item creation?   
Hello,

In which event is it most appropriate to create a CommandBar button that
displays information about the currently open document?

A little background on my Add In: VB6 COM add-in written to display and
change a Custom Document Property for any Word document.

Right now, I create my button on the IDTExtensibility2_OnConnection event,
which essentially fires when Word is launched.  I then update the caption of
the button to display the custom document property on the following events
raised for the Word Application object:

DocumentChange
DocumentOpen
NewDocument

I am noticing, however, that as users move through documents, in some cases,
the reference to my button seems to go away, and when I try to set the
button's caption property I get an "Object variable or with block not set"
exception.

What is the best practice for creating items in the CommandBar in Word for
an addin whose items could change depending on the document that is opened?
Should I recreated the button on DocumentChange???  That seems like a lot of
overhead (and potentially "screen flickering") just to maintain a reference
to the button...

TIA!!!

Brian
date: Tue, 14 Aug 2007 16:12:19 -0400   author:   Brian

Re: CommandBar item creation?   
Hi Brian

What version of Word are you using? Can you show us the code that you're 
using to create and update the button? And, what template is used to create 
the documents for which this button is appropriate?

Hope this helps.

Shauna Kelly.  Microsoft MVP.
http://www.shaunakelly.com/word


"Brian"  wrote in message 
news:787D5BB5-825F-493F-B639-30D4F6B992CE@microsoft.com...
> Hello,
>
> In which event is it most appropriate to create a CommandBar button that
> displays information about the currently open document?
>
> A little background on my Add In: VB6 COM add-in written to display and
> change a Custom Document Property for any Word document.
>
> Right now, I create my button on the IDTExtensibility2_OnConnection event,
> which essentially fires when Word is launched.  I then update the caption 
> of
> the button to display the custom document property on the following events
> raised for the Word Application object:
>
> DocumentChange
> DocumentOpen
> NewDocument
>
> I am noticing, however, that as users move through documents, in some 
> cases,
> the reference to my button seems to go away, and when I try to set the
> button's caption property I get an "Object variable or with block not set"
> exception.
>
> What is the best practice for creating items in the CommandBar in Word for
> an addin whose items could change depending on the document that is 
> opened?
> Should I recreated the button on DocumentChange???  That seems like a lot 
> of
> overhead (and potentially "screen flickering") just to maintain a 
> reference
> to the button...
>
> TIA!!!
>
> Brian
>
date: Sat, 18 Aug 2007 10:41:14 +1000   author:   Shauna Kelly

Re: CommandBar item creation?   
I am using Word XP (aka Word 2002).

I am in the process of updating the code.  I am using the standard code to 
create buttons on the application level CommandBars object.

The button is shown/displayed regardless of what template is used to create 
the document.

Apparently the WindowActivate method is the appropriate method to create any 
UI that is Document centric, as is the case for me.  But would still 
appreciate any feedback anyone might have for creating UI elements (i.e. 
buttons on CommandBar) that are document centric (i.e. can be different for 
each document that is opened)...

-Brian


"Shauna Kelly"  wrote in message 
news:%233%23OICT4HHA.1484@TK2MSFTNGP06.phx.gbl...
> Hi Brian
>
> What version of Word are you using? Can you show us the code that you're 
> using to create and update the button? And, what template is used to 
> create the documents for which this button is appropriate?
>
> Hope this helps.
>
> Shauna Kelly.  Microsoft MVP.
> http://www.shaunakelly.com/word
>
>
> "Brian"  wrote in message 
> news:787D5BB5-825F-493F-B639-30D4F6B992CE@microsoft.com...
>> Hello,
>>
>> In which event is it most appropriate to create a CommandBar button that
>> displays information about the currently open document?
>>
>> A little background on my Add In: VB6 COM add-in written to display and
>> change a Custom Document Property for any Word document.
>>
>> Right now, I create my button on the IDTExtensibility2_OnConnection 
>> event,
>> which essentially fires when Word is launched.  I then update the caption 
>> of
>> the button to display the custom document property on the following 
>> events
>> raised for the Word Application object:
>>
>> DocumentChange
>> DocumentOpen
>> NewDocument
>>
>> I am noticing, however, that as users move through documents, in some 
>> cases,
>> the reference to my button seems to go away, and when I try to set the
>> button's caption property I get an "Object variable or with block not 
>> set"
>> exception.
>>
>> What is the best practice for creating items in the CommandBar in Word 
>> for
>> an addin whose items could change depending on the document that is 
>> opened?
>> Should I recreated the button on DocumentChange???  That seems like a lot 
>> of
>> overhead (and potentially "screen flickering") just to maintain a 
>> reference
>> to the button...
>>
>> TIA!!!
>>
>> Brian
>>
>
>
date: Mon, 20 Aug 2007 13:16:20 -0400   author:   Brian

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us