VBA call VSTO Method
VBA call VSTO Method
Sub CallVSTOMethod()
Dim addIn As COMAddIn
Dim automationObject As Object
Set addIn = Application.COMAddIns("AddInNameInRegistry")
Set automationObject = addIn.Object
Dim bSuccess As Boolean
Dim sEngineID As String
Dim sDisplayName As String
sEngineID = ""
bSuccess = automationObject.IsAuthorizedUser(sEngineID, sDisplayName)
MsgBox (bSuccess & vbCrLf & sEngineID & vbCrLf & sDisplayName)
Set automationObject = Nothing
Set addIn = Nothing
End Sub
Note: If not sure about the "AddInName", you can use below method to enumerate all the AddIns loaded.
Dim addIn As COMAddIn
Dim automationObject As Object
Dim nAddInsCount As Integer
nAddInsCount = Application.COMAddIns.Count
For Each addIn In Application.COMAddIns
MsgBox(addIn.ProgId) 'This is the AddIn name you registered in Registry
Next
Besides, you can also use index to refer to a particular AddIn as follow:
Set addIn = Application.COMAddIns(1)
Sub CallVSTOMethod()
Dim addIn As COMAddIn
Dim automationObject As Object
Set addIn = Application.COMAddIns("AddInNameInRegistry")
Set automationObject = addIn.Object
Dim bSuccess As Boolean
Dim sEngineID As String
Dim sDisplayName As String
sEngineID = ""
bSuccess = automationObject.IsAuthorizedUser(sEngineID, sDisplayName)
MsgBox (bSuccess & vbCrLf & sEngineID & vbCrLf & sDisplayName)
Set automationObject = Nothing
Set addIn = Nothing
End Sub
Note: If not sure about the "AddInName", you can use below method to enumerate all the AddIns loaded.
Dim addIn As COMAddIn
Dim automationObject As Object
Dim nAddInsCount As Integer
nAddInsCount = Application.COMAddIns.Count
For Each addIn In Application.COMAddIns
MsgBox(addIn.ProgId) 'This is the AddIn name you registered in Registry
Next
Besides, you can also use index to refer to a particular AddIn as follow:
Set addIn = Application.COMAddIns(1)
Comments
Post a Comment