Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

Enumerating References in Outlook error - Illegal Function Call

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg J - 06 Nov 2006 23:54 GMT
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
Greg J - 07 Nov 2006 00:31 GMT
correction to the above...

I do need to have a database open and when I do, the following code
runs without error but returns the references collection of the access
database that is open, not Outlook (as the code would indicate)

Function fnGetReference(strRef As String) As String

   Dim ref As Access.Reference
   Dim refs As Access.References

   fnGetReference = "ERROR"
   Set refs = Access.References
   For Each ref In refs
       If UCase(ref.Name) = UCase(strRef) Then fnGetReference =
ref.FullPath
   Next
   Err.Clear
   
   Set accApp = Nothing
   
End Function
Greg J - 07 Nov 2006 00:31 GMT
correction to the above...

I do need to have a database open and when I do, the following code
runs without error but returns the references collection of the access
database that is open, not Outlook (as the code would indicate)

Function fnGetReference(strRef As String) As String

   Dim ref As Access.Reference
   Dim refs As Access.References

   fnGetReference = "ERROR"
   Set refs = Access.References
   For Each ref In refs
       If UCase(ref.Name) = UCase(strRef) Then fnGetReference =
ref.FullPath
   Next
   Err.Clear
   
End Function
Greg J - 07 Nov 2006 00:32 GMT
correction to the above...

I do need to have a database open and when I do, the following code
runs without error but returns the references collection of the access
database that is open, not Outlook (as the code would indicate)

Function fnGetReference(strRef As String) As String

   Dim ref As Access.Reference
   Dim refs As Access.References

   fnGetReference = "ERROR"
   Set refs = Access.References
   For Each ref In refs
       If UCase(ref.Name) = UCase(strRef) Then fnGetReference =
ref.FullPath
   Next
   
End Function
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.