5. Replace the entire program code with the following program code:
Option Explicit
'-----------------------------------------------------
'Member Variables
'-----------------------------------------------------
'Reference to the AddIn Connection
Dim WithEvents ThisAddIn As grafexe.AddinHook
'Reference to the Grafics Designer Application
Dim WithEvents GrafApp As grafexe.Application
'-----------------------------------------------------
'WithEvents AddInInstance IDTExtensibility2 (automatic)
'-----------------------------------------------------
'------------------------------------------------------
'This
method connects the AddIn To the Graphic Designer Application
'------------------------------------------------------
Private Sub AddinInstance_OnConnection(ByVal Application As
Object, _
ByVal ConnectMode As
AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object,
custom() As Variant)
On Error GoTo AddinInstance_OnConnection_Error
'--------------------------------------------------------
' Hook up to the Graphics Designer application.IAddInHookEvents
interface.
' It is necessary referencing the application this AddIn hooks
up to
'--------------------------------------------------------
Dim GDApplication As grafexe.Application
Set GDApplication = Application
If (Not GDApplication Is Nothing) Then
'----------------------------------------------------
' Explanation on filters ( first parameter to
AddIns.Attach() )
'
' sbAddInFilterExecute : AddIn is not shown in the AddIn-
Menu
' (ThisAddIn_Execute() is NOT called)
' sbAddInFilterNone : AddIn is shown in the AddIn-Menu
and by
' clicking on the AddIn's menu entry
ThisAddIn_Execute()
' is called (see the figure below)
'------------------------------------------------------
Set ThisAddIn =
GDApplication.Addins.Attach(sbAddinFilterNone, "Create Rectangle")
Set GrafApp = GDApplication
RegisterApplicationMenus
End If
VBA for Automated Configuration
4.5 AddIns
MDM - WinCC: Scripting (VBS, ANSI-C, VBA)
System Manual, 11/2008,
2421