Delete some text in the last table

S

S1lverface

Hi,

I have a word document with 28 tables. The last table has one column / one
row , with one paragraph of text. The paragraph is split into two bits by 8
dots in the middle of it (........) followed by more text and some blank rows.

I must keep the text before the dots.

I want my macro to select that last table and then delete everything AFTER
the 8 dots, ie all text, numbers and blank rows, but leave everything before
the dots (Keeping the dots is optional). Or I suppose code it to delete all
of the text, and then input the sentence would also work ?

If you could help I would be pleased.

Many thanks again to all
 
D

Doug Robbins - Word MVP

Use the following:

Dim drange As Range
With ActiveDocument
Set drange = .Tables(.Tables.Count).Cell(1, 1).Range
With drange
.Start = .Start + InStr(.Text, "........") - 1
.End = .End - 1
.Delete
End With
End With

Be aware however that the eight dots might not be exactly what you think
they are. To get the above to work, I had to separate the two pieces of
text by
dot space dot space dot space dot space dot space dot space dot space dot

and then delete the spaces so that I just had the 8 dots.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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