Hi Ken
Thanks for the reply.
We are creating a custom commandbar for office 2003 -word, outlook, excel
and powepoint using visual studio 2003 extensibility project..
This commandbar will have 3 buttons and 3 dropdown. For each control we are
intializing unique tag property. Here we are handling click event for the
buttons and onchange event for dropdowns.
But the problem is that when we open a MS Word instance and select the
value from drop down controls available in command bar.
Now if we open another instance of MS Word we face following problem :
1.Drop down values are same as selected in first instance.
2.Also events are not getting fired for the second instance of the word.
We are creating the commanbar in the Onstartup event of Connect.cs. Is that
we have to create a new instance of toolbar when a document is opened.
Following code is used to create commandbar
// DECLARE
CommandBar oStandardBar = null;
Object oMissing = System.Reflection.Missing.Value;
oStandardBar = (CommandBar)oWord.CommandBars.Add("IAMWordToolbar",
MsoBarPosition.msoBarTop, oMissing, true);
oStandardBar.Protection=Microsoft.Office.Core.MsoBarProtection.msoBarNoChangeVisible;
oStandardBar.Visible = true;
// ADD CONTROLS IN TOOLBAR
if (oStandardBar != null)
{
// LEGAL ENTITY
cmbLegalEntity =
(CommandBarComboBox)oStandardBar.Controls.Add(MsoControlType.msoControlDropdown, oMissing, oMissing, oMissing, oMissing);
cmbLegalEntity.Caption =
dsLabel.Tables["locStrings"].Rows[0]["legal_entity"].ToString();
cmbLegalEntity.Style = MsoComboStyle.msoComboLabel;
cmbLegalEntity.Change += new
Microsoft.Office.Core._CommandBarComboBoxEvents_ChangeEventHandler(this.cmbLegalEntity_Change);
cmbLegalEntity.Width =250;
cmbLegalEntity.Tag="LegalEntity";
cmbLegalEntity.ListIndex = 0;
// HELP
btnHelpLegalEntity =
(CommandBarButton)oStandardBar.Controls.Add(MsoControlType.msoControlButton,
oMissing, oMissing, oMissing, true);
btnHelpLegalEntity.Visible = true;
btnHelpLegalEntity.Tag="LegalEntityHelp"
btnHelpLegalEntity.Style = MsoButtonStyle.msoButtonIconAndCaption;
btnHelpLegalEntity.FaceId = 984;
btnHelpLegalEntity.Click += new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnHelpLegalEntity_Click);
// SECURITY CLASSIFICATION
cmbSecurityClass =
(CommandBarComboBox)oStandardBar.Controls.Add(MsoControlType.msoControlDropdown, oMissing, oMissing, oMissing, oMissing);
cmbSecurityClass.Caption =
dsLabel.Tables["locStrings"].Rows[0]["secureity_class"].ToString();
cmbSecurityClass.Style = MsoComboStyle.msoComboLabel;
cmbSecurityClass.Change +=new
Microsoft.Office.Core._CommandBarComboBoxEvents_ChangeEventHandler(cmbSecurityClass_Change);
cmbSecurityClass.ListIndex = 0;
cmbSecurityClass.Tag="Security"
// HELP
btnHelpSecurityClass =
(CommandBarButton)oStandardBar.Controls.Add(MsoControlType.msoControlButton,
oMissing, oMissing, oMissing, true);
btnHelpSecurityClass.Visible = true;
btnHelpSecurityClass.Tag="SecurityHelp";
btnHelpSecurityClass.Style = MsoButtonStyle.msoButtonIconAndCaption;
btnHelpSecurityClass.FaceId = 984;
btnHelpSecurityClass.Click += new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnHelpSecurityClass_Click);
// RECORD TYPE
cmbRecordType =
(CommandBarComboBox)oStandardBar.Controls.Add(MsoControlType.msoControlDropdown, oMissing, oMissing, oMissing, oMissing);
cmbRecordType.Style = MsoComboStyle.msoComboLabel;
cmbRecordType.Change +=new
Microsoft.Office.Core._CommandBarComboBoxEvents_ChangeEventHandler(cmbRecordType_Change);
cmbRecordType.ListIndex=0;
cmbRecordType.Tag="RecordType";
// HELP
btnHelpRecordClass =
(CommandBarButton)oStandardBar.Controls.Add(MsoControlType.msoControlButton,
oMissing, oMissing, oMissing, true);
btnHelpRecordClass.Visible = true;
btnHelpRecordClass.Style = MsoButtonStyle.msoButtonIconAndCaption;
btnHelpRecordClass.FaceId = 984;
btnHelpRecordClass.Tag="RecordTypeHelp"
btnHelpRecordClass.Click += new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnHelpRecordClass_Click);
}}
Even tried setting CustomizationContext= OWord.ActiveDocument. But still its
not working. Can you tell what might be wrong in code?
Thanks
Rita