Code:
Namespace Compilazione_cartiglio
<ProgIdAttribute("Compilazione_cartiglio.StandardAddInServer"), _
GuidAttribute("1af1b978-6025-4499-a4b6-607bad526aa8")> _
Public Class StandardAddInServer
Implements Inventor.ApplicationAddInServer
' Inventor application object.
Private m_inventorApplication As Inventor.Application
Private WithEvents m_fillButtonDef As ButtonDefinition
#Region "ApplicationAddInServer Members"
Public Sub Activate(ByVal addInSiteObject As Inventor.ApplicationAddInSite, ByVal firstTime As Boolean) Implements Inventor.ApplicationAddInServer.Activate
' This method is called by Inventor when it loads the AddIn.
' The AddInSiteObject provides access to the Inventor Application object.
' The FirstTime flag indicates if the AddIn is loaded for the first time.
' Initialize AddIn members.
m_inventorApplication = addInSiteObject.Application
' create the button definition
Dim controlDefs As ControlDefinition
controlDefs = m_inventorApplication.CommandManager.ControlDefinitions
m_fillButtonDef = controlDefs.AddButtonDefinition( _
"Inserisci dati cartiglio", _
"insdaticart", _
CommandTypesEnum.kQueryOnlyCmdType, _
"{1af1b978-6025-4499-a4b6-607bad526aa8}", _
"Inserisci dati Excel nel cartiglio", _
"Inserisci dati nel cartiglio")
If firstTime Then
'create a new command bar (toolbar) and make it visible.
Dim commandBars As CommandBars
commandBars = m_inventorApplication.UserInterfaceManager.CommandBars
Dim commandbar As CommandBar
commandbar = commandBars.Add("Cartiglio", "compcartmacros", "{1af1b978-6025-4499-a4b6-607bad526aa8}")
commandbar.Visible = True
'add the control to the command bar.
commandbar.Controls.AddButton(m_fillButtonDef)
End If
End Sub