K
Kevin
I Have an Add-In that creates a menu item under the FILE menu. Add works
great, I just want to know hoe to move the button up from below the EXIT
command. Obviously I could use the customize and move it manually but I'm
adding this COM Add-In to 200 systems and I don't want to do it manually.
Here's my sample
' Constants for menu item in Office application.
Public Const CBR_NAME As String = "File" 'menu name
Public Const CTL_CAPTION As String = "Save to Drive"
Public Const CTL_KEY As String = "SavetoDrive"
Public Const CTL_NAME As String = "Save to Drive"
Function CreateAddInCommandBarButton(ByVal Application As Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object) As Office.CommandBarButton
' This procedure assigns a reference to the Application
' object passed to the OnConnection event to a global
' object variable. It then creates a new command bar
' button and returns a reference to the button to the
' OnConnection event procedure. The advantage to
' putting this code in a public module is that if you
' have more than one add-in designer in the project, you can
' call this procedure from each of them rather than
' duplicating the code.
Dim cbrMenu As Office.CommandBar
Dim ctlBtnAddIn As Office.CommandBarButton
' Return reference to Application object and store it in public variable
' so that other procedures in add-in can use it.
Set gobjAppInstance = Application.ActiveExplorer
' Return reference to command bar.
Set cbrMenu = gobjAppInstance.CommandBars(CBR_NAME)
' Add button to call add-in from command bar, if it doesn't
' already exist.
' Constants are declared at module level.
' Look for button on command bar.
Set ctlBtnAddIn = cbrMenu.FindControl(Tag:=CTL_KEY)
If ctlBtnAddIn Is Nothing Then
' Add new button.
Set ctlBtnAddIn = cbrMenu.Controls.Add(Type:=msoControlButton, _
Parameter:=CTL_KEY)
' Set button's Caption, Tag, Style, and OnAction properties.
With ctlBtnAddIn
.Caption = CTL_CAPTION
.Tag = CTL_KEY
.Style = msoButtonCaption
' Use AddInInst argument to return reference
' to this add-in.
.OnAction = PROG_ID_START & AddInInst.ProgId _
& PROG_ID_END
' .Picture = picPicture
End With
End If
' Return reference to new commandbar button.
Set CreateAddInCommandBarButton = ctlBtnAddIn
Thanks in advance.
Also if anyone know how to add a custom icon programatically please le me
know.
Kevin
(e-mail address removed)
great, I just want to know hoe to move the button up from below the EXIT
command. Obviously I could use the customize and move it manually but I'm
adding this COM Add-In to 200 systems and I don't want to do it manually.
Here's my sample
' Constants for menu item in Office application.
Public Const CBR_NAME As String = "File" 'menu name
Public Const CTL_CAPTION As String = "Save to Drive"
Public Const CTL_KEY As String = "SavetoDrive"
Public Const CTL_NAME As String = "Save to Drive"
Function CreateAddInCommandBarButton(ByVal Application As Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object) As Office.CommandBarButton
' This procedure assigns a reference to the Application
' object passed to the OnConnection event to a global
' object variable. It then creates a new command bar
' button and returns a reference to the button to the
' OnConnection event procedure. The advantage to
' putting this code in a public module is that if you
' have more than one add-in designer in the project, you can
' call this procedure from each of them rather than
' duplicating the code.
Dim cbrMenu As Office.CommandBar
Dim ctlBtnAddIn As Office.CommandBarButton
' Return reference to Application object and store it in public variable
' so that other procedures in add-in can use it.
Set gobjAppInstance = Application.ActiveExplorer
' Return reference to command bar.
Set cbrMenu = gobjAppInstance.CommandBars(CBR_NAME)
' Add button to call add-in from command bar, if it doesn't
' already exist.
' Constants are declared at module level.
' Look for button on command bar.
Set ctlBtnAddIn = cbrMenu.FindControl(Tag:=CTL_KEY)
If ctlBtnAddIn Is Nothing Then
' Add new button.
Set ctlBtnAddIn = cbrMenu.Controls.Add(Type:=msoControlButton, _
Parameter:=CTL_KEY)
' Set button's Caption, Tag, Style, and OnAction properties.
With ctlBtnAddIn
.Caption = CTL_CAPTION
.Tag = CTL_KEY
.Style = msoButtonCaption
' Use AddInInst argument to return reference
' to this add-in.
.OnAction = PROG_ID_START & AddInInst.ProgId _
& PROG_ID_END
' .Picture = picPicture
End With
End If
' Return reference to new commandbar button.
Set CreateAddInCommandBarButton = ctlBtnAddIn
Thanks in advance.
Also if anyone know how to add a custom icon programatically please le me
know.
Kevin
(e-mail address removed)