A
Amir
Hi,
I'm using Visual Basic Studio 6 in order to build installation program for
my macro/template.
The installation program copies the template to the Startup directory of
Word, and adds appropriate command bars buttons.
My question is how should I declare the variables in VB in order to do that?
As opposed to VBA, in VB I am not able to declare the following types of
variables: CommandBarPopup, CommandBarButton, CommandBarControl, CommandBar,
KeyBinding.
In VBA, I would have used:
Dim objCmdBrPp As CommandBarPopup, objCmdBtn As CommandBarButton
Dim myCustom As CommandBarControl, cbcMenuBar As CommandBar
Dim iHelpIndex As Integer, kbNew As KeyBinding
Const strMenuName As String = "MyMenu"
Application.CommandBars("Menu Bar").Controls(strMenuName).Delete
CommandBars.DisplayTooltips = True
Set cbcMenuBar = Application.CommandBars("Menu Bar")
iHelpIndex = cbcMenuBar.Controls("Help").Index
Set myCustom = cbcMenuBar.Controls.Add(Type:=msoControlPopup,
Before:=iHelpIndex)
With myCustom
.Caption = strMenuName
With .Controls.Add(Type:=msoControlButton)
.Caption = "MyCaption"
.OnAction = "macro1"
.FaceId = 9678
.ShortcutText = "Alt+Ctrl+A"
Set kbNew = KeyBindings.Add(KeyCategory:=wdKeyCategoryCommand, _
Command:="Document_Open", KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt,
wdKeyA))
Kind Regards,
Amir.
I'm using Visual Basic Studio 6 in order to build installation program for
my macro/template.
The installation program copies the template to the Startup directory of
Word, and adds appropriate command bars buttons.
My question is how should I declare the variables in VB in order to do that?
As opposed to VBA, in VB I am not able to declare the following types of
variables: CommandBarPopup, CommandBarButton, CommandBarControl, CommandBar,
KeyBinding.
In VBA, I would have used:
Dim objCmdBrPp As CommandBarPopup, objCmdBtn As CommandBarButton
Dim myCustom As CommandBarControl, cbcMenuBar As CommandBar
Dim iHelpIndex As Integer, kbNew As KeyBinding
Const strMenuName As String = "MyMenu"
Application.CommandBars("Menu Bar").Controls(strMenuName).Delete
CommandBars.DisplayTooltips = True
Set cbcMenuBar = Application.CommandBars("Menu Bar")
iHelpIndex = cbcMenuBar.Controls("Help").Index
Set myCustom = cbcMenuBar.Controls.Add(Type:=msoControlPopup,
Before:=iHelpIndex)
With myCustom
.Caption = strMenuName
With .Controls.Add(Type:=msoControlButton)
.Caption = "MyCaption"
.OnAction = "macro1"
.FaceId = 9678
.ShortcutText = "Alt+Ctrl+A"
Set kbNew = KeyBindings.Add(KeyCategory:=wdKeyCategoryCommand, _
Command:="Document_Open", KeyCode:=BuildKeyCode(wdKeyControl, wdKeyAlt,
wdKeyA))
Kind Regards,
Amir.