Deleting objects on page

  • Thread starter Roderick O'Regan
  • Start date
R

Roderick O'Regan

If a document has a number of pages and one of those pages has a
number of objects (in this case text boxes) how can I select these and
then delete them, please?

There is an "Ah, yes but..." factor here: these pages have a very deep
top margin of about 9 cm. The objects are located in that space
between the top margin and the top edge of the paper.

My code of:
Activedocument.bookmarks("\page").Range.Select
Selection.Delete

....removes everything within the boundaries of the page's margins but
nothing outside of these.

Is there a way of selecting these extra-marginal objects, please?

Regards

Roderick
 
S

Stefan Blom

The text boxes could be anchored to the header. To delete header
contents, you need code such as the following:

Selection.Sections(1).Headers(wdHeaderFooterPrimary) _
..Range.Delete

Selection.Sections(1).Headers(wdHeaderFooterEvenPages) _
..Range.Delete

Selection.Sections(1).Headers(wdHeaderFooterFirstPage) _
..Range.Delete

--
Stefan Blom
Microsoft Word MVP


in message
news:[email protected]...
 
R

Roderick O'Regan

Thanks Stefan for the message.

I wish they were in the headers/footers! Life would be easier as I
could then apply what you have suggested below.

However, these are, and must remain so, on the body of the page but
outside the boundaries of the margins.

Regards

Roderick
 
S

Stefan Blom

To which paragraph(s) are the text boxes anchored?

--
Stefan Blom
Microsoft Word MVP


in message
 
S

Stefan Blom

This is strange. If you want to, I could take a look at the document.
Email it to (e-mail address removed).

--
Stefan Blom
Microsoft Word MVP


in message
 
R

Roderick O'Regan

Thanks for the offer Stefan but I might have resolved the problem.

This problem always seemed to happen when the objects were on the last
page of the document.

I had the code:
Activedocument.bookmarks("\Page").range.select
Selection.delete

This deleted all the text within the margin but not the surrounding
objects.

These were anchored to the last paragraph in the last page.

Of course, when I looked at the Help topic a little more deeply I saw
the sentence which said that the \Page built-in bookmark does not
select the last paragraph mark on the last page.

As the objects were anchored to this hence they were not deleted.

I resolved it then with:
.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
.Delete

That seemed to do the trick! Objects removed!

Thanks for your help.

Regards

Roderick
 
S

Stefan Blom

Yes, it is a known fact that the "\page" bookmark does not include the
final paragraph mark of a document. I would have commented on this
earlier, but in a previous message you stated that the text boxes were
anchored to the *first* paragraph of the page... Anyway, I'm glad you
got it sorted!

--
Stefan Blom
Microsoft Word MVP


in message
 

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