Results 1 to 14 of 14
  1. #1
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Conflicting References? (VB6/ Office 2000)

    <P ID="edit" class=small>(Edited by AlanMiller on 19-Aug-05 16:17. )</P>I have working code in a Word 2000 template that I'm trying to compile as ActiveX DLL in VB6. As far as I can see, the references point to the same libraries in both projects. However, when I use the intellisense dropdowns on a Shape object, I see a different list of members. VB is complaining that the .TextFrame Property can't be found (consistent with it not appearing in its intellisense), but it happily pops up in my VBA.

    As said, I can't see any differences between the reference libraries, but I guess there must be. Any thoughts please?

    Alan

    [Edit] - I did find a difference between the "Visual Basic For Applications" references.
    In Word VBA it points to C:Program FilesCommon FilesMicrosoft SharedVBAVBA6VBE6.DLL
    while in VB6 it points to C:WINDOWSSYSTEMMSVBVM60.DLL

    When I try to change it in VB6, I am unable to, since it's reported as being in use... not surprising since it's the main runtime module I guess. ???

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Conflicting References? (VB6/ Office 2000)

    Have you declared the shape object to be of type Word.Shape?

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conflicting References? (VB6/ Office 2000)

    I had it declared as simply "Shape" and the compiler didn't like .TextFrame in the code:

    With shp.Container.TextFrame

    If I now declare it as "Word.Shape" it doesn't like .Container.

    I remembered helping someone out with Shapes, using the .OLEFormat property, and it seems the compiler doesn't mind taking that route:

    <div style="width: 100%; background-color: #FFFFFF;"><code><font color=black>With docRef
    For i = 1 To .InlineShapes.Count
    With .InlineShapes.Item(i)
    If .Type = wdInlineShapeOLEControlObject Then _
    If .OLEFormat.ClassType = "Forms.TextBox.1" Then _
    If .OLEFormat.Object.TextFrame.HasText Then _
    .OLEFormat.Object.TextFrame.TextRange.Fields.Updat e
    <font color=blue>End</font color=blue> With
    <font color=blue>Next</font color=blue> i
    <font color=blue>End</font color=blue> With
    </font color=black></code></div hiblock>
    It remains to be seen if it works properly though. <img src=/S/crossfingers.gif border=0 alt=crossfingers width=17 height=16>

    Alan

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Conflicting References? (VB6/ Office 2000)

    In Word 2002, if I create a document, drop in a floating picture and a textbox, and then use this sniffer to inspect all of the properties, I definitely do not see a Container. Maybe you had a PowerPoint object before??

    Sub SniffShapes()
    Dim shp As Word.Shape
    For Each shp In ActiveDocument.Shapes
    If shp.TextFrame.HasText Then
    MsgBox "Text frame contains:" & vbCrLf & shp.TextFrame.TextRange.Text
    Else
    MsgBox "No text frame in this Shape"
    End If
    Stop 'inspect properties in view>locals
    Next
    End Sub

    I notice your snippet above relates to InlineShapes, which may be more various in nature...

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Conflicting References? (VB6/ Office 2000)

    Container is a property in Word VBA, the example from the Word 2002 VBA help is

    Msgbox ActiveDocument.Shapes(1).OLEFormat.Object.Containe r.Name

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Conflicting References? (VB6/ Office 2000)

    I was very unclear, sorry. I was only looking at the top level (per the post with <code>shp.Container.TextFrame</code>).

  7. #7
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conflicting References? (VB6/ Office 2000)

    The code in <post#=509,987>post 509,987</post: > appears to work as I'd hoped, in an ActiveX DLL, built in VB6. I must confess to being rather overwhelmed by all the possibilities when trying to reference Shapes... it's like Ranges in XL, but makes less sense! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Alan

  8. #8
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conflicting References? (VB6/ Office 2000)

    when declaring variables, ALWAYS qualify the date type with the library.

    Dim home as Word.Range
    Dim onthe as Excel.Range
    Dim rng as SomeOtherLibrary.Range

    Then there's never a mix up when using multiple libraries.

  9. #9
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conflicting References? (VB6/ Office 2000)

    Hi Howard

    You sound like just "da man" to sort this one. To recap,
    1. <LI>I'm looking for some code that will work in BOTH Word 9.0 VBA AND VB6.
      <LI>It must be able to identify/ select the Textboxes that contain text, in a Word doc.
      <LI>It must use the appropriate referencing in libraries used in both VBA and VB6.
    Requirement 3. is just an echo of your excellent general advice, which I always try to keep in mind, along with "Look both ways before crossing the road" and "Don't stick your <img src=/w3timages/censored.gif alt=censored border=0> in the blender". At present though, I'm unable to comply: VB forcibly uses MSVBVM60.DLL to reference VBA, and won't let go of it, while Word VBA similarly insists on gluing itself together with C:Program FilesCommon FilesMicrosoft SharedVBAVBA6VBE6.DLL. Referencing a shape appears to be quite distinct in both environments, regardless of what libraries I try.

    Anyway, I look forward to any working code you may come up with.

    Alan

  10. #10
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conflicting References? (VB6/ Office 2000)

    The "proper" solition is to write the code in VB6 as an ActiveX DLL, then the code can be used either fron VBA or within VB 6 with no change.
    The details of how this needs to be done can be simple or very complex and may require that you seek paid help.

  11. #11
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conflicting References? (VB6/ Office 2000)

    No matter... I haven't a clue about where to start either <img src=/S/confused.gif border=0 alt=confused width=15 height=20>. Paid "help", however, would be irrelevant and redundant. I have already formulated my own code that works in a VB6 ActiveX DLL, which in turn works when referenced in a Word VBA project. So the project does work as planned. But the question remains as to how to use the same code in "raw" VBA, as is used in the VB6 ActiveX DLL. This comes back to what uses what library inflexibly, and how said libraries reference the objects in question (see thread above for details). Thanks for trying anyway.

    Alan

  12. #12
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Conflicting References? (VB6/ Office 2000)

    I don't know about the VB6 runtime, but there are no Shape objects or properties in the VBE6.DLL library, at least according to the Object Browser. Is it there in the VB runtime, or might VB be adding an extraneous library?

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

    Re: Conflicting References? (VB6/ Office 2000)

    There are shapes in the Office library, however, and in the individual application libraries.
    Charlotte

  14. #14
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Conflicting References? (VB6/ Office 2000)

    I noted that myself, adding further to the confusion. I thought about your suggestion:

    > might VB be adding an extraneous library?

    in the context of perhaps different versions of libraries conflicting or something like that. In desperation, I copied every library involved to an "install location folder" and renamed those remaining in their original locations. Then went through the process of "reinstalling" the required library copies for both Office and VB6, as they were "asked for". Surprise, surprise <img src=/S/smile.gif border=0 alt=smile width=15 height=15> things now work as I'd have expected at square 1. Both methods of "drilling down" to the required shape properties work in both environments. So, still in the dark as to the reason (didn't need to use library updates) but now have the problem solved.

    Thanks for that steer.
    Alan

Posting Permissions

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