Exiting from a textbox

R

Roderick O'Regan

I have a textbox into which my procedure has inserted an inlineshape -
a photo for a CV.
The code next causes the selection to collapse within the text box.

I now want to break out of that text box and cause the selection point
to move to paragraph mark close by.

Manually, I've figured out to achieve this I would press ESC key
twice. I've translated this to some code and arrived at the following:
With Selection
.ShapeRange.TextFrame.TextRange.Select
.Collapse
.ShapeRange.Select
.Collapse
End With
Nothing! The cursor justs sits inside the box.
I've tried using the ("\Page") bookmark to break out but still no joy.

Reading through this newsgroup I've seen some great code to make
txtboxes even do cartwheels but nothing on how to get out of the pesky
critters.

Can anyone help, please?

Roderick
 
S

Shauna Kelly

Hi Roderick

Assuming that the cursor is within a text box, then the following will
select the paragraph to which the text box is anchored. You can see the
anchors by doing Tools > Options > View and ticking the "Object anchors"
box.

Sub SelectShapeAnchor()

Dim tb As Shape

Set tb = Selection.ShapeRange(1)

tb.Anchor.Select
Selection.Collapse wdCollapseStart

End Sub
 

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