VBA/Excel/Access/Word/Application/References
Locating and Referencing Libraries in Code
<source lang="vb">
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
</source>
Requires a reference to Microsoft InfoPath.
<source lang="vb">
Private Sub cmdRegisterForm_Click()
Dim ap As New InfoPath.ExternalApplication ap.RegisterSolution ThisWorkbook.Path & "\manifest.xsf" ap.Quit Set ap = Nothing
End Sub
</source>