[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.
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:
Sub AddShapeToCell()
'Set rngTableCell as Range for anchor point
Dim rngTableCell As Range
Set rngTableCell = ActiveDocument.Tables(1).Cell(1, 1).Range
'Add shape and set Zorder
With ActiveDocument.Shapes.AddShape(Type:=msoShapeRectangle, Left:=2, _
Top:=2, Width:=30, Height:=10, Anchor:=rngTableCell)
.ZOrder 2
End With
End Sub
Hope this helps.
PS. Is this post http://www.vbforums.com/showthread.p...03#post2453003 resolved?
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.