I have a function which works fine on my machine if the Microsoft Office 16 Object Library
is added in the reference
.
My question is, how do I use late binding
so that I don't have to add the Microsoft Office 16 Object Library from the list of references.
On my Start up form I have:
Private Sub Form_Load()
On Error Resume Next
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT CustomerName FROM tblCustomers")
If Err.Number <> 0 Then
MsgBox "Back-end data Not found: " & Err.Number & " " & Err.Description & " Please locate the data
file!", , "Data file not found"
Call AttachBackEndFile
End If
rs.Close
Set rs = Nothing
DoCmd.Close acForm, "frmStartUp"
DoCmd.OpenForm "frmMain"
End Sub
Function for opening the File Dialog:
Public Function AttachBackEndFile() As Boolean
On Error GoTo 0
Dim oFileDialog As FileDialog
Dim result As VbMsgBoxResult
Set oFileDialog = FileDialog(msoFileDialogFilePicker)
oFileDialog.show
If oFileDialog.SelectedItems.Count = 1 Then
result = RelinkTables(oFileDialog.SelectedItems(1))
If result = vbCancel Then
AttachBackEndFile = False
End If
AttachBackEndFile = True
Else
AttachBackEndFile = False
End Sub
Thank you!