Here is the most simple iLogic example, how to create button in default AddIns tab
You can modify method
Private Sub Button1_OnExecute(context As NameValueMap)
at line 52 to change the button behavior.
Sub Main()
TryDeleteButton()
CreateButton()
End Sub
'Can be replaced with any GUID
Const ClientId = "{6FE44211-19D7-4CFF-855E-DCF34864AD19}"
Const button1InternalName As String = "Button1InternalName"
Const button1Sharedvariable As String = "Button1InternalName"
Private Sub TryDeleteButton()
If SharedVariable.Exists(button1Sharedvariable) Then
Try
Dim button1Def As ButtonDefinition = SharedVariable.Value(button1Sharedvariable)
button1Def.Delete()
Catch
'Ignore errors
End Try
End If
End Sub
Private Sub CreateButton()
Dim button1Def As ButtonDefinition =
ThisApplication.CommandManager.ControlDefinitions.AddButtonDefinition(
"Button1",
button1InternalName,
CommandTypesEnum.kEditMaskCmdType,
ClientId,
"Description of Button1",
"ToolTip of Button1",
Nothing, 'Small icon
Nothing, 'Large icon
ButtonDisplayEnum.kAlwaysDisplayText
)
'Add button click handler
AddHandler button1Def.OnExecute, AddressOf Button1_OnExecute
'Store button reference in SharedVariable
SharedVariable.Value(button1Sharedvariable) = button1Def
'The most simple way, how to add button to Ribbon to AddIns tab
button1Def.AutoAddToGUI()
End Sub
Private Sub Button1_OnExecute(context As NameValueMap)
'Implement what happens when Button1 was clicked
MsgBox("Button 1 clicked")
End Sub