Drawing shapes

F

Fuzzhead

The following macro insert a textbox with the $ sign in it. How do I get out
of the textbox and back into the main document after it runs?

Dim textbox As Shape
Dim i
i = Selection.Information(wdVerticalPositionRelativeToPage)
ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 35, _
i - 5, 22, 24).Select
Selection.ShapeRange.TextFrame.TextRange.Select
Selection.Collapse
Selection.Font.Size = 14
Selection.TypeText Text:="$"
Selection.ShapeRange.Fill.Visible = msoFalse
Selection.ShapeRange.Line.Visible = msoFalse
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Fill.Transparency = 0#
CommandBars("Stop Recording").Visible = False
Selection.ShapeRange.Select
 
J

Jezebel

Better to write your macro so you don't change the selection; then the
problem doesn't arise --

With ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 35,
Selection.Information(wdVerticalPositionRelativeToPage)
- 5, 22, 24)
With .TextFrame.TextRange
.Text = "$"
.Font.Size = 14
End With
.Fill.Visible = msoFalse
.Line.Visible = msoFalse
End With


But probably simpler still is to define your textbox, ready-formatted and
positioned relative to its anchor, as an Autotext entry; then just insert
it.
 
F

Fuzzhead

Thank you for the help and info.

Fuzzhead


Jezebel said:
Better to write your macro so you don't change the selection; then the
problem doesn't arise --

With ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 35,
Selection.Information(wdVerticalPositionRelativeToPage)
- 5, 22, 24)
With .TextFrame.TextRange
.Text = "$"
.Font.Size = 14
End With
.Fill.Visible = msoFalse
.Line.Visible = msoFalse
End With


But probably simpler still is to define your textbox, ready-formatted and
positioned relative to its anchor, as an Autotext entry; then just insert
it.
 

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