VBA/Excel/Access/Word/Application/References

Материал из VB Эксперт
Перейти к: навигация, поиск

Locating and Referencing Libraries in Code

 
Function CreateLibRef(strLibName as String)
    Dim ref As Reference
    On Error GoTo CreateLibRef_Err
    "Create new reference
    Set ref = References.AddFromFile(strLibName)
    CreateLibRef = True
Exit_CreateLibRef:
    Exit Function
CreateLibRef_Err:
    Dim intAnswer As Integer
    Dim strLocation As String
    intAnswer = MsgBox("Library Not Found, Attempt to Locate?", _
        vbYesNo, "Error")
    If intAnswer = vbYes Then
       strLocation = InputBox("Please Enter the Location of the Library")
       Resume
    Else
        CreateLibRef = False
        GoTo Exit_CreateLibRef
    End If
End Function



Requires a reference to Microsoft InfoPath.

 
Private Sub cmdRegisterForm_Click()
    Dim ap As New InfoPath.ExternalApplication
    ap.RegisterSolution ThisWorkbook.Path & "\manifest.xsf"
    ap.Quit
    Set ap = Nothing
End Sub