Add a shape text box

C

Cresta

Hello and help
I need code to add a shape text box to my document and position it on the
left margin on the next line down from the cursor.

Any ideas
Thanks
 
J

Jay Freedman

Cresta said:
Hello and help
I need code to add a shape text box to my document and position it on
the left margin on the next line down from the cursor.

Any ideas
Thanks

It would be much simpler to define a style that includes a properly
formatted frame
(http://sbarnhill.mvps.org/WordFAQs/MarginalText.htm#TrueMarginalText). The
style can be assigned a toolbar button or keyboard shortcut to make it easy
to apply, no macro needed.

If for some reason that doesn't do what you need, then look at the VBA help
for the AddTextbox method of the Shapes collection object, something like

Dim myBox As Shape
Set myBox = ActiveDocument.Shapes.AddTextbox( _
Orientation:=msoTextOrientationHorizontal, _
Top:=12, Left:=-72, _
Height:=72, Width:=64, _
Anchor:=Selection.Range)
With myBox
.Fill.Visible = msoFalse
.Line.Visible = msoFalse
.TextFrame.TextRange.Text = "hello"
End With

You'll need to work with this to get the vertical position (.Top) correct,
because the measurement is from the top line of the current paragraph, not
from the cursor position.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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