Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Feb 2001
    Location
    Jackson, Mississippi, USA
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trouble with object reference (VBA - Word 2000)

    We use an object reference in VBA code for Word 97 and it works fine. Now converting to Word 2000 and unable to figure out why it generates run-time error.

    Under Word 97
    dim oAuthorsQ as object
    dim members as object

    set members = new clsautharr

    set oAuthorsQ = createobject("mlis_authors.member_query")
    oAuthorsQ.Membership members

    the code above works fine under 97
    (returning array of names from Foxpro table)


    but under 2000 generates error on execution of last line of code as follows:
    Run-time error 98.
    A property or method cannot include a reference to a private object, either as an argument or as a return value.

    Under the class module property window, the instancing property is private and only other option is PublicNotCreateable.

    I tried to declare the objects as public before instead of dimming in private module, but that didn't work either.

    Thanks.
    Ann Brandon

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Trouble with object reference (VBA - Word 2000)

    It generates a runtime error because you have apparently declared clsautharr as a user-defined class object and you're assigning it to an object variable and then trying to pass that object to the oAuthorsQ.Membership method. The message is telling you that you can't do that.

    VB/VBA 6 seems to be different in a number of ways from 5, and I think you're running into one of them. If you open the class module in WordPad, you'll see attributes that you may not be able to set from within the VB editor. Here's an example:

    Attribute VB_Name = "clsCapAcct"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False

    In Access, changing the Exposed property to True allows you to use the class from a library database. If you change Creatable to True, you can declare an object as an instance of that class. I haven't tried this with VB 6 or Word, but it's worth a try.
    Charlotte

  3. #3
    New Lounger
    Join Date
    Feb 2001
    Location
    Jackson, Mississippi, USA
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    thank you!

    Hi Charlotte,
    I changed the instancing property in the VB Editor from private to publicnotcreatable and that changed the attribute vb_creatable to false and the attribute vb_exposed to true.

    That did the trick!

    The instancing property was not included in the properties window under VB5, but it is included under VB6.

    You're great!

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: thank you!

    Glad it worked. I can never remember exactly what the individual attributes in the class module are for, but I manage to remember which one I need to tweak to expose them. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •