Enumerating References - "Illegal Function Call" 
Author Message
 Enumerating References - "Illegal Function Call"

Hi,

I have the following code in an Access VBA module;

    Dim ref As Reference

    For Each ref In References

        ' Do Something with ref.

    Next ref

Unfortunately, accessing 'References' gives: Run-time error '7952' - You
made an illegal function call.

I tried;

    Dim refs As References

    Set refs = Access.Application.References ' This gives the same error.

Any input gratefully received

Colin



Tue, 26 Jul 2005 01:35:30 GMT  
 Enumerating References - "Illegal Function Call"

Quote:

>I have the following code in an Access VBA module;

>    Dim ref As Reference

>    For Each ref In References

>        ' Do Something with ref.

>    Next ref

>Unfortunately, accessing 'References' gives: Run-time error '7952' - You
>made an illegal function call.

>I tried;

>    Dim refs As References

>    Set refs = Access.Application.References ' This gives the same error.

This works for me

        Sub ListReferences()
        Dim ref As Reference
                For Each ref In References
                        Debug.Print ref.Name, ref.FullPath
                Next
        End Sub

Maybe you have  references problem?  ;-)

--
Marsh
MVP [MS Access]



Tue, 26 Jul 2005 04:31:22 GMT  
 Enumerating References - "Illegal Function Call"
I don't have any problem with similar code.  Here is the code I tested in
A2K:

****Code starts****
Public Sub TestReferences()

  Dim ref As Access.Reference

  For Each ref In References
    Debug.Print ref.Name
  Next

End Sub
****Code ends****

--
HTH
Van T. Dinh
MVP (Access)


Quote:
> Hi,

> I have the following code in an Access VBA module;

>     Dim ref As Reference

>     For Each ref In References

>         ' Do Something with ref.

>     Next ref

> Unfortunately, accessing 'References' gives: Run-time error '7952' - You
> made an illegal function call.

> I tried;

>     Dim refs As References

>     Set refs = Access.Application.References ' This gives the same error.

> Any input gratefully received

> Colin



Tue, 26 Jul 2005 07:48:08 GMT  
 Enumerating References - "Illegal Function Call"
You may have some other object that declares a reference
type. Try

Dim ref As Access.Reference.

For each ref in Application.References

.....

Or you may be trying to enumerate the references because
you have a faulty reference:  Unfortunately, that is never
going to work properly: it won't tell you what you want to
know even when you get it working without failure.

(david)


Quote:
> Hi,

> I have the following code in an Access VBA module;

>     Dim ref As Reference

>     For Each ref In References

>         ' Do Something with ref.

>     Next ref

> Unfortunately, accessing 'References' gives: Run-time error '7952' - You
> made an illegal function call.

> I tried;

>     Dim refs As References

>     Set refs = Access.Application.References ' This gives the same error.

> Any input gratefully received

> Colin



Tue, 26 Jul 2005 08:05:02 GMT  
 Enumerating References - "Illegal Function Call"
Thanks to everyone who offered suggestions.

I'm still stuck with the same error.

I made a new installation of XP.
I made a new installation of Office XP & Office XP Developer.

I created a New Project.
I created a New Module.
I checked Tools>References>Microsoft Access 10.0 Object Library

I created a New Procedure;

Option Explicit

Public Sub main()

    Dim n As Integer

    n = References.Count

End Sub

I still get the same error: Run-time error '7952' - You made an illegal
function call.

I've tried using the References Object from the ...Applications
Extensibility 5.3 Library - and that works fine.

Unfortunately, I want to access References from Outlook VBA - and the
References Object from the Extensibility library is not inherited/available
by Outlook's Application Object.

I don't really see what else I can even try, except calling MS Technical
Support.

Colin



Wed, 27 Jul 2005 04:29:10 GMT  
 Enumerating References - "Illegal Function Call"
See http://members.rogers.com/douglas.j.steele/AccessReferenceErrors.html

... and http://support.microsoft.com/default.aspx?scid=KB;en-us;197110.
--
Bruce M. Thompson, Microsoft Access MVP

Quote:
>>No Email, Please. Keep all communications

    within the newsgroups so that all might benefit.<<


Quote:
> Thanks to everyone who offered suggestions.

> I'm still stuck with the same error.

> I made a new installation of XP.
> I made a new installation of Office XP & Office XP Developer.

> I created a New Project.
> I created a New Module.
> I checked Tools>References>Microsoft Access 10.0 Object Library

> I created a New Procedure;

> Option Explicit

> Public Sub main()

>     Dim n As Integer

>     n = References.Count

> End Sub

> I still get the same error: Run-time error '7952' - You made an illegal
> function call.

> I've tried using the References Object from the ...Applications
> Extensibility 5.3 Library - and that works fine.

> Unfortunately, I want to access References from Outlook VBA - and the
> References Object from the Extensibility library is not inherited/available
> by Outlook's Application Object.

> I don't really see what else I can even try, except calling MS Technical
> Support.

> Colin



Wed, 27 Jul 2005 07:59:43 GMT  
 Enumerating References - "Illegal Function Call"

Quote:
> > Unfortunately, I want to access References from Outlook VBA - and the
> > References Object from the Extensibility library is not inherited/available
> > by Outlook's Application Object.

Uhhh ... I'm not sure what you mean by this. Maybe I responded too quickly?
--
Bruce M. Thompson, Microsoft Access MVP

Quote:
>>No Email, Please. Keep all communications

    within the newsgroups so that all might benefit.<<


Wed, 27 Jul 2005 08:41:23 GMT  
 Enumerating References - "Illegal Function Call"
Hi Bruce,

Thank you for taking the trouble to try and help me with this problem

The problem for me is actually using the References Class.

The following link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/modc...
l/deconAutomatingVisualBasicEditor.asp explains that the VBE property is not
available in Outlook.

In Access VBA;

Public Sub main()

    Dim n As Integer

    n = VBE.ActiveVBProject.References.Count ' This works OK

    n = References.Count ' This gives run-time error 7952

End Sub

In Outlook VBA;

Public Sub main()

    Dim n As Integer

    n = VBE.ActiveVBProject.References.Count ' Application.VBE is not
available to use

    n = References.Count ' This gives run-time error 7952

End Sub

Because I want to use the References Class within Outlook, I must use the
Access MSACC.OLB library implementation.

Strictly speaking, I should have said that the Outlook Application Class
doesn't inherit the VBE Class.

Whilst trying to solve this, I've now come up with the additional problem
that I can't uninstall Office XP Developer - Looking round the newsgroups,
this seems to a fairly widespread issue.

Thanks again

Colin



Wed, 27 Jul 2005 11:12:36 GMT  
 Enumerating References - "Illegal Function Call"
Hi Bruce,

Thank you for taking the trouble to try and help me with this problem

The problem for me is actually using the References Class.

The following link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/modc...
l/deconAutomatingVisualBasicEditor.asp explains that the VBE property is not
available in Outlook.

In Access VBA;

Public Sub main()

    Dim n As Integer

    n = VBE.ActiveVBProject.References.Count ' This works OK

    n = References.Count ' This gives run-time error 7952

End Sub

In Outlook VBA;

Public Sub main()

    Dim n As Integer

    n = VBE.ActiveVBProject.References.Count ' Application.VBE is not
available to use

    n = References.Count ' This gives run-time error 7952

End Sub

Because I want to use the References Class within Outlook, I must use the
Access MSACC.OLB library implementation.

Strictly speaking, I should have said that the Outlook Application Class
doesn't inherit the VBE Class.

Whilst trying to solve this, I've now come up with the additional problem
that I can't uninstall Office XP Developer - Looking round the newsgroups,
this seems to a fairly widespread issue.

Thanks again

Colin



Wed, 27 Jul 2005 11:12:36 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. CopyObject gets "Illegal function call" error

2. "Illegal function call" when loading program

3. Calling a VBScript Function from "onChange"

4. Calling the "Scan" Function in Acrobat

5. "Call default Internet connection"-function

6. "Pure Virtual Function called"

7. "Pure Virtual Function Call" Problem

8. "Program Used for Illegal Purpose"

9. VB6 "illegal opeation" message in Win95

10. Error "Illegal use of property"?

11. VBasic3 Shell-function and NT - "illegal function call"

12. Unbound control - illegal use of "null"

 

 
Powered by phpBB® Forum Software