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: Wed, 7 Mar 2007 01:36:00 -0800,    group: microsoft.public.word.vba.addins        back       


Commandbar for Word Add-in   
I am working on a Word Add-in in Visual Studio 2005 (C#, .Net2.0). I know 
this is a VB newsgroup, but it is the best i could find.

For this add-in i need a toolbar, which i create using 
'Microsoft.Office.Core.CommandBar'. and '.CommandBarButton'. It does show up 
nice and events are hooked up without a problem.

But I run into problems when I want to change the button state or when 
en/disabling  it. In specific conditions trying to do that will result in a 
COMException. I can't remember the exact exception code, but searching around 
returned an 'object missing' description.

My current theory is, that my references to these buttons become invalid 
after a document change/close/etc. The events are still working though, for 
which i can think of some reasons.
Currently I lookup the buttons on a document change 
('Microsoft.Office.Interop.Word.ApplicationEvents4_DocumentChangeEventHandler') using:
'Microsoft.Office.Interop.Application .. CommandBars.FindControl()'. Which 
is not ideal, since it requires that the captions of the buttons are unique. 
And besides that, it is far from ideal anyway that this seems necessary.

Just like Jens Sauer in 'An AfterCloseEvent' I could use such an event too. 
For now I'm just using the BeforeClose event, and mimic the 'do you want to 
safe' dialog, so I can determine whether a document has really closed or not. 
But this brings in localization issues. Ideally I'd like a 'DocumentClosing' 
and 'DocumentSave' event.
date: Wed, 7 Mar 2007 01:36:00 -0800   author:   Alex Haan Alex

Google
 
Web ureader.com


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