Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Apr 2002
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Charts collection in Word (VB/Word)

    Hi guys, here we go again.

    Now, I'm trying to retrieve the charts that contains a Word document.

    if I have selected part of my document, how can I know that there is a chart inside?
    I wonder if there is a chart collection. I got this with tables doing the following:

    If oWord.Selection.Tables.Count > 0 Then

    End If

    Going further, I tried to get the charts in the whole document doing the following: (it's c++ but very simple)

    if ( shapePtr->Type == msoEmbeddedOLEObject )
    {
    if ( shapePtr->OLEFormat->ProgID == "MSGraph.Chart.8" ) // The shape has a chart
    {
    }
    }

    However, the number of shapes in my document is always 0.


    Do you guys know how I can get this?

    Thanks a lot and sorry for my stupid questions [img]/forums/images/smilies/tongue.gif[/img]

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Charts collection in Word (VB/Word)

    You will need to look at all members of ActiveDocument.Shapes and ActiveDocument.InlineShapes.
    Look for .Type = wdInlineShapeEmbeddedOLEObject and .Field.Code = EMBED MSGraph.Chart.8 s
    So your code will be something like...
    <pre>Dim inlShp as InlineShape
    For each inlShp in ActiveDocument.InlineShapes
    if inlShp.Type = wdInlineShapeEmbeddedOLEObject Then
    if inlShp.Field.Code = "EMBED MSGraph.Chart.8 s" Then
    <font color=448800>' put your code here</font color=448800>
    end if
    end if
    Next inlShp
    </pre>

    StuartR

  3. #3
    Star Lounger
    Join Date
    Apr 2002
    Posts
    51
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Charts collection in Word (VB/Word)

    Thanks again, Stuart!!

    That works great [img]/forums/images/smilies/smile.gif[/img]

Posting Permissions

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