Results 1 to 3 of 3

Thread: [RESOLVED] Add line shape diretly in tablecell

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    91

    Resolved [RESOLVED] Add line shape diretly in tablecell

    I use word automation in my VB6 appl.
    I want to add a line shape directly into my tablecell.
    Can i do that? I know i can do that manually
    I want it directly in the cell for positioning reasons!

    Now i can only get it somewhere in my doc page
    I make sure my cursor is in the tablecell
    then i use this command:

    Code:
    Appword.activedocument.shapes.addLine(bgx,bgy,enx,eny).select
    Maybe i have to do something with the shapearea first (or how you call the big reactangle shape which popups up when je add a shape).

    Someone any suggestions.

  2. #2
    Lively Member New2vba's Avatar
    Join Date
    Sep 2005
    Location
    UK
    Posts
    95

    Re: Add line shape diretly in tablecell

    Here's one way of adding a rectangle to a cell (it may not be the best way, but I simply recorded a Macro and messed around with it a little).

    VB Code:
    1. Sub AddShapeToCell()
    2.  
    3. 'Set rngTableCell as Range for anchor point
    4. Dim rngTableCell As Range
    5.     Set rngTableCell = ActiveDocument.Tables(1).Cell(1, 1).Range
    6.  
    7.         'Add shape and set Zorder
    8.         With ActiveDocument.Shapes.AddShape(Type:=msoShapeRectangle, Left:=2, _
    9.             Top:=2, Width:=30, Height:=10, Anchor:=rngTableCell)
    10.             .ZOrder 2
    11.         End With
    12.  
    13. End Sub

    Hope this helps.

    PS. Is this post http://www.vbforums.com/showthread.p...03#post2453003 resolved?
    Last edited by New2vba; May 7th, 2006 at 01:17 PM.
    "Those things we must learn to do, we must learn by doing" (or hope somebody else will take pity and help out )

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Oct 2005
    Posts
    91

    Re: Add line shape diretly in tablecell

    Thx this works great.
    I didn't know about the anchor.
    I allso found an other method on internet using selection.information(wdHorizontalPositionRelativeToPage and some with vertical) this works allso and without the anchor, but here you need to put the cursor in the table. But i prefer your method using the anchor.
    Thx for finding the solution.

Posting Permissions

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



Click Here to Expand Forum to Full Width