creating Toolbar on Word 2000 using built-in Visual Basic Editor

S

sagar.gadre

Hi All,

I have some queries.

I am creating Toolbar on Word 2000 using built-in Visual
Basic Editor.

First query is regarding CommandBarButtons Click event not
firing using WithEvents keyword.


Also since the CommandBar is created dynamically I dont
know how to
take the values entered in its various controls at runtime.
When I enter something into ComboBox and I shift to
another control
the value entered in the comboBox is lost. How to prevent
this.

My Code is as follows:

Public WithEvents cbcCommandBarButton As
Office.CommandBarButton
Dim cbrCommandBar As CommandBar
Public cbcCommandBarListBox As CommandBarComboBox
Public cbcCommandBarCategoryListBox As CommandBarComboBox
Public cbcCommandBarSearchCriteriaListBox As
CommandBarComboBox
Dim m_IE As InternetExplorer

Sub NewToolBar()

' If the command bar exits, remove it.
On Error Resume Next
Application.CommandBars("Marsh Knowledge Exchange").Delete

' Add the command bar to the application's
' CommandBars collection.
Set cbrCommandBar = _
Application.CommandBars.Add
cbrCommandBar.Name = "Knowledge Exchange"

' Add command button control to the control's
' collection of CommandBar objects.
With cbrCommandBar.Controls
Set cbcCommandBarButton = _
..Add(msoControlLabel)
' ' Set properties of the command button.
'Add the following lines of code just below the block
of 'code beginning with the comment "Set properties of the
command button."
' Set properties of the drop-down list box.
Set cbcCommandBarListBox = _
..Add(Type:=msoControlDropdown)
With cbcCommandBarListBox
..AddItem " Knowledge Exchange Home"
..AddItem " Practice Home"
..AddItem " Research Centre"
..AddItem " My KX"
..AddItem " My Assignments"
..Width = 138
..ListIndex = 5
..Caption = " Knowledge Exchange Home "
..Style = msoComboLabel
..BeginGroup = True
..OnAction = "DisplayMessage"
..Tag = "lstPractice"
End With

'Code to create the Search Criteria Combo-box
Set cbcCommandBarSearchCriteriaListBox = _
..Add(Type:=msoControlComboBox)

'Code to create the Search Criteria Combo-box

'Code to create the Search Categories Combo-box
Set cbcCommandBarCategoryListBox = _
..Add(Type:=msoControlComboBox)
With cbcCommandBarCategoryListBox
..AddItem " Search Knowledge Exchange Home"
..AddItem " Search Google"

..Width = 138
'.ListIndex = 6
'.Caption = " "
..Style = msoComboNormal
..BeginGroup = True
..OnAction = "Message"
..Tag = "lstCategory"
End With

' Set cbcCommandBarButton = _
' .Add(Type:=msoControlButton)
'
' ' Set properties of the command button.
' With cbcCommandBarButton
' .Style = msoButtonIconAndCaption
' .Caption = "My Big Button"
' .FaceId = 19
' .OnAction = "Message"
' .Tag = "My Big Button"
' End With




End With



cbrCommandBar.Visible = True


End Sub



Could you please tell me how these problems are solved.
Can you send
me the code if possible.

Regards,
Sagar Gadre.
 

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