我需要通过VBA启用COM加载项。加载项已存在于COM加载项下,但在Excel崩溃时不会被选中。

Sub hyp()
    Dim objAddIn As Object
    For i = 1 To Application.COMAddIns.Count

        Set objAddIn = Application.COMAddIns.Item(i)
        On Error Resume Next
        If Application.COMAddIns.Item(i).Description = "Oracle Smart View for Office" Then
            'MsgBox Application.COMAddIns.Item(i).Description
            'NEED TO ENABLE THE COM ADDIN

        Else
        End If
    Next i
End Sub

最佳答案

Public Sub Connect_COM_AddIn(Name As String)

    Dim ndx As Integer

    For ndx = 1 To Application.COMAddIns.Count
        If Application.COMAddIns(ndx).Description = Name Then
            Application.COMAddIns(ndx).Connect = True
            Exit For
        End If
    Next
End Sub

08-08 02:45