G
Greg J
Hi,
I am trying to enumerate the references linked in Outlook VBA with
mixed results. Sometimes I get an error Illegal Function Call (Error
7952). I have just worked out that this error occurs if MS Access is
not open at the time. If I open Access and just leave a blank window
(ie no database opened), the code works without error. As soon as I
close the access application, the error reappears.
I understand that the references collection comes from the Access
object but how do I enumerate the Outlook references from Outlook VBA
using the Access object without having to have Access open at the time?
MS Access object library is linked in the references collection in
Outlook VBA.
Here is a sample of the code that I am currently trying to get working:
Function fnGetReference(strRef As String) As String
Dim accApp As New Access.Application
Dim ref As Access.Reference
Dim refs As Access.References
Set accApp = Access.Application
fnGetReference = "ERROR"
Set refs = accApp.References <<<< ERROR OCCURS ON THIS LINE
For Each ref In refs
If UCase(ref.Name) = UCase(strRef) Then fnGetReference =
ref.FullPath
Next
End Function
I am trying to enumerate the references linked in Outlook VBA with
mixed results. Sometimes I get an error Illegal Function Call (Error
7952). I have just worked out that this error occurs if MS Access is
not open at the time. If I open Access and just leave a blank window
(ie no database opened), the code works without error. As soon as I
close the access application, the error reappears.
I understand that the references collection comes from the Access
object but how do I enumerate the Outlook references from Outlook VBA
using the Access object without having to have Access open at the time?
MS Access object library is linked in the references collection in
Outlook VBA.
Here is a sample of the code that I am currently trying to get working:
Function fnGetReference(strRef As String) As String
Dim accApp As New Access.Application
Dim ref As Access.Reference
Dim refs As Access.References
Set accApp = Access.Application
fnGetReference = "ERROR"
Set refs = accApp.References <<<< ERROR OCCURS ON THIS LINE
For Each ref In refs
If UCase(ref.Name) = UCase(strRef) Then fnGetReference =
ref.FullPath
Next
End Function