Results 1 to 13 of 13

Thread: Compile this

  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Compile this

    Would someone take a minute and compile this simple VBE code and tell me what you get. I get type mismatch error (Word 97) unless I declare vbComp as Object. You'll need a reference to VBA extensions.

    Dim vbComp As VBIDE.VBComponent
    Dim vbComps As VBIDE.VBComponents

    'Either of these lines cause the error
    Set vbComps = ThisDocument.VBProject.VBComponents
    or
    Set vbComps = Application.VBE.ActiveVBProject.VBComponents

    I'm trying to loop thru all the components in a project like this:

    for each vbComp in vbComps
    debug.print vbComp.Name
    'bla bla bla
    next

    Yes, I can do it with Object declarations, but I really want to know why I get the error.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile this

    I don't find a data type of VBIDE.VBComponents. VBComponents is a collection. I think you need:

    <pre>Dim vbComps As Collection
    </pre>

    Legare Coleman

  3. #3
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile this

    Do you have a reference to the VBA Extensions library?

    Yes, VBComponents is a collection, a collection of VBE components, so it should work.

    Nevertheless, I tested your suggestion and get the same error.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  4. #4
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile this

    Kevin,

    This works for me:

    Dim vbComps As VBComponents
    Dim vbComp As VBComponent

    Set vbComps = ActiveDocument.AttachedTemplate.VBProject.VBCompon ents
    For Each vbComp In vbComps
    Debug.Print vbComp.Name
    Next
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  5. #5
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile this

    That's what I was afraid of. It should work for me too. I found identical code from an Excel programmer and pasted it into and Excel mod. Same error.

    Something fishy going on here...

    Thanks for testing for me.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  6. #6
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile this

    Geoff,

    Do me a favor, please, and tell me the name and location of the VBA Extensibility library for Office 97 (vba5). I think my problem is related to the fact that I have some Office 2000 components installed (namely Outlook 2000) and Word wants to use the library for VBA6. The library I reference is

    crogram filescommon filesmicrosoft sharedvbavba6VBE6EXT.OLB

    My guess is that is NOT the same library for VBA5. Thanks.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  7. #7
    5 Star Lounger
    Join Date
    Dec 2000
    Location
    Reading/Swindon, Berkshire, United Kingdom
    Posts
    664
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile this

    Either Geoff's invisible or he's gone home.

    try this - i think it's right...

    crogram filescommon filesmicrosoft sharedvbaVBEEXT1.OLB

    Brooke

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile this

    Brooke,

    While you were posting, I was hunting and testing. You are correct, that is the VB5 VBA Extensibility Library. And when I manually put that back on the reference list and retried my code -- it Worked!

    What a goose chase. That means the VB6 library installed OVER the vb5 library when I installed Outlook 2000. Watch out y'all.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  9. #9
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile this

    Geoff,

    See Brooke's post and mine after.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  10. #10
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile this

    Kevin,

    I can only duck in now and then.

    My library is different- I've got Microsoft Visual StudioVB98VB6ext.olb which has a time/date stamp of 18/6/98. I assume it came from VB6.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  11. #11
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile this

    Thanks though. It looks like that library has any number of incarnations. Are you deving in Office 2000 or 97?
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  12. #12
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile this

    Kevin,

    OK, I've Office 2000. But the same code, with the same reference set, also works in Word 97.

    And that was Visual Basic 6 extensibility, not VBA extensibility. Sorry, I've rechecked and I was wrong before. Sorry to mislead you- the one that worked for me was the same as Brooke's.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  13. #13
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Compile this

    Geoff,

    Ok, thanks. I'm all squared away now.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

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