Results 1 to 6 of 6
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word: What Table and cell? (2000, XP)

    Hi all, a Word VBA question.

    I have a word document with shapes in it. Each shape is anchored to text in one of the tables of the doc.

    I would like to get:

    - the table's index of the range object the shape is anchored to
    - the table's row of the range object the shape is anchored to

    I currently have:

    For Each oSh In oDoc.Shapes
    If InStr(oSh.Name, "Oval") > 0 Then
    oSheet.Range("A65536").End(xlUp).Offset(1).Value = sFilename
    oSheet.Range("A65536").End(xlUp).Offset(, 1).Value = oSh.Name
    oSheet.Range("A65536").End(xlUp).Offset(, 2).Value = oSh.Anchor.Paragraphs(1).Range.Text
    oSheet.Range("A65536").End(xlUp).Offset(, 3).Value = oSh.Anchor.Paragraphs(1).Range.Information(wdActiv eEndPageNumber)
    oSheet.Range("A65536").End(xlUp).Offset(, 4).Value = oSh.Anchor.Paragraphs(1).Range.Information(wdFirst CharacterLineNumber)

    So I get the shape's name and the paragraph's text, page # and line #.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

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

    Re: Word: What Table and cell? (2000, XP)

    See <post#=250704>post 250704</post#> for a method to retrieve the table index - it's for the Selection object but it can easily be adapted for your needs.

    Information(wdEndOfRangeRowNumber) returns the table row number that contains the end of the specified selection or range.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word: What Table and cell? (2000, XP)

    Thanks, I'll give this a try.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word: What Table and cell? (2000, XP)

    Worked fine.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  5. #5
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word: What Table and cell? (2000, XP)

    If you want to avoid the loop:
    http://word.mvps.org/faqs/macrosvba/...exNoOfPara.htm

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16> Klaus

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Word: What Table and cell? (2000, XP)

    Thanks Klaus.

    I managed to get what I needed with Hans' suggestion.
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

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