In Word 2000 I have a floating text box in a cell of an many-row table. I
am trying to create a macro that will delete the box, the paragraph mark
that it is anchored to, and the 3 blank paragraphs after it (all in the same
cell). "Selection.ShapeRange.Delete" will delete the text box, but the
cursor jumps to the top of the document. I tried some GoBack commands to
bring the cursor back to where the box had been but they don't always take
the cursor to the right location.
What I really want to do is start the macro with the text box already
selected by the user, then deselect the box and put the cursor immediately
in front of it so I can delete the paragraph containing it. What code do I
use to that is equivalent to "deselect the text box and put the cursor
immediately before the box"? ("Collapse" puts the cursor in front of the
text that is in the box, not before the box.)
TIA,
Vivian
Hi Vivian,
Define a Range object variable and set it to the anchor of the textbox.
Then, even if the Selection jumps when you delete the textbox, you can still
locate its former anchor.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
> In Word 2000 I have a floating text box in a cell of an many-row table. I
> am trying to create a macro that will delete the box, the paragraph mark
[quoted text clipped - 16 lines]
>
> Vivian
Vivian Carroll - 16 Nov 2005 13:50 GMT
Thanks Jonathan,
I'll have to see if I can figure out how to do that!
Vivian
> Hi Vivian,
>
[quoted text clipped - 22 lines]
> >
> > Vivian
Jean-Guy Marcil - 16 Nov 2005 15:36 GMT
Vivian Carroll was telling us:
Vivian Carroll nous racontait que :
> Thanks Jonathan,
>
> I'll have to see if I can figure out how to do that!
Hers's a little something to get you going:
'_______________________________________
Dim BoxRange As Range
Set BoxRange = Selection.ShapeRange(1).Anchor
Selection.Delete
BoxRange.Select
'_______________________________________

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Vivian Carroll - 18 Nov 2005 03:18 GMT
Thank you Jean-Guy,
You saved me a lot of time by providing the code that you did. I added one
more line to it and it works as I wanted it to!
Vivian
> Vivian Carroll was telling us:
> Vivian Carroll nous racontait que :
[quoted text clipped - 13 lines]
> BoxRange.Select
> '_______________________________________