How do I add a rectangle shape at the current insertion point?

R

Robin Tucker

Having trouble adding a shape at the current insertion point in the
document, when the user clicks a button on one of my forms:

Set theShape = ActiveDocument.Shapes.Add(msoShapeRectangle, 0#, 0#, 10#,
10#)

I want to add a rectangle, of size 10, 10 at the current position. Seems
that the selection object does not have a Shapes property, although it does
have an "inline shapes" property - this property does not have an "addshape"
method, only addpicture, addole etc.

Can anyone tell me how to do this?

Thanks.
 
D

Doug Robbins - Word MVP

To insert a shap at the position of the cursor, use:

Dim NewShape As Shape, t As Long, l As Long
l = Selection.Information(wdHorizontalPositionRelativeToTextBoundary)
t = Selection.Information(wdVerticalPositionRelativeToPage) -
Selection.Paragraphs(1).Range.Information(wdVerticalPositionRelativeToPage)
Set NewShape = ActiveDocument.Shapes.AddShape(msoShapeRectangle, l, t, 10,
10, Selection.Range)


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
R

Robin Tucker

ohhh thanks. I'd never have worked that one out for myself in a million
years.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top