Sub AddReferenceMSODLL()
On Error GoTo Err_AddReferenceMSODLL
Dim refItem As Reference
Dim strFile As String
Dim intRefCount As Integer
Dim intCount As Integer
intCount = 0
intRefCount = Access.References.Count
strFile = "C:\Program Files\Common Files\Microsoft Shared\Office10\MSO.DLL"
Set refItem = Access.References.AddFromFile(strFile)
If Access.References.Count = intRefCount + 1 Then
Debug.Print "Reference Set = " & strFile
Exit Sub
End If
strFile = "C:\Program Files\Common Files\Microsoft Shared\Office11\MSO.DLL"
Set refItem = Access.References.AddFromFile(strFile)
If Access.References.Count = intRefCount + 1 Then
Debug.Print "Reference Set = " & strFile
Exit Sub
End If
strFile = "C:\Program Files\Common Files\Microsoft Shared\Office12\MSO.DLL"
Set refItem = Access.References.AddFromFile(strFile)
If Access.References.Count = intRefCount + 1 Then
Debug.Print "Reference Set = " & strFile
Exit Sub
End If
strFile = "D:\Program Files\Common Files\Microsoft Shared\Office10\MSO.DLL"
Set refItem = Access.References.AddFromFile(strFile)
If Access.References.Count = intRefCount + 1 Then
Debug.Print "Reference Set = " & strFile
Exit Sub
End If
strFile = "D:\Program Files\Common Files\Microsoft Shared\Office11\MSO.DLL"
Set refItem = Access.References.AddFromFile(strFile)
If Access.References.Count = intRefCount + 1 Then
Debug.Print "Reference Set = " & strFile
Exit Sub
End If
strFile = "D:\Program Files\Common Files\Microsoft Shared\Office12\MSO.DLL"
Set refItem = Access.References.AddFromFile(strFile)
If Access.References.Count = intRefCount + 1 Then
Debug.Print "Reference Set = " & strFile
Exit Sub
End If
Call MsgBox("A Reference must be set to the Microsoft Office Object Library")
Exit_AddReferenceMSODLL:
Exit Sub
Err_AddReferenceMSODLL:
If Err.Number = 29060 Then
intCount = intCount + 1
Debug.Print "File Not Found " & intCount
Resume Next
ElseIf Err.Number = 53 Then
intCount = intCount + 1
Debug.Print "File Not Found " & intCount
Resume Next
ElseIf Err.Number = 32813 Then
Debug.Print "Reference already exists."
Resume Exit_AddReferenceMSODLL
Else
Call MsgBox(Err.Description & vbCrLf & "Error Number= " & Err.Number & vbCrLf & _
" In procedure AddReferenceMSODLL of Module basCommonDialog")
Resume Exit_AddReferenceMSODLL
End If
End Sub
Function GetFolderPath() As String
On Error GoTo Err_GetFolderPath
Dim fldrpkr As FileDialog
Set fldrpkr = Application.FileDialog(msoFileDialogFolderPicker)
Dim vrtSelectedItem As Variant
With fldrpkr
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
GetFolderPath = vrtSelectedItem
Next vrtSelectedItem
Else
End If
End With
Set fldrpkr = Nothing
Exit_GetFolderPath:
Exit Function
Err_GetFolderPath:
Call MsgBox(Err.Description & vbCrLf & "Error Number: " & Err.Number & vbCrLf & _
" In procedure GetFolderPath of Module basFolderDialog")
Resume Exit_GetFolderPath
End Function