Access.2007.VBA.Bibl..

(John Hannent) #1

Return a reference to the command bar..


Set cbrMenu = pappAccess.CommandBars(“Report Design”)

Add a button to call the add-in from the command bar, if it doesn’t already exist.


Look for the button on the command bar.


Set cbbAddIn = _
cbrMenu.FindControl(Tag:=”Rename Report Controls”)
If cbbAddIn Is Nothing Then

Add the new button.


Set cbbAddIn = _
cbrMenu.Controls.Add(Type:=msoControlButton, _
Parameter:=”Rename Report Controls”)

Set the button’s Caption, Tag, Style, and OnAction properties.


With cbbAddIn
.Caption = “Rename &Report Controls”
.Tag = “Rename Report Controls”
.Style = msoButtonCaption

Run the main add-in function.


.OnAction = PROG_ID_START & AddInInst.ProgId _
& PROG_ID_END
End With
End If

Return a reference to the new commandbar button.


Set CreateReportCommandBarButton = cbbAddIn

ErrorHandlerExit:
Exit Function

ErrorHandler:
AddInErr Err
Resume ErrorHandlerExit

End Function

Function RemoveAddInCommandBarButton(ByVal _
RemoveMode As AddInDesignerObjects.ext_DisconnectMode)

Creating COM Add-ins with Visual Basic 6 13

Free download pdf