Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2006

Tip: Looking for answers? Try searching our database.

Deleting objects on page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roderick O'Regan - 01 Aug 2006 23:43 GMT
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
Stefan Blom - 02 Aug 2006 08:51 GMT
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

Signature

Stefan Blom
Microsoft Word MVP

> 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
[quoted text clipped - 16 lines]
>
> Roderick
Roderick O'Regan - 02 Aug 2006 09:28 GMT
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

>The text boxes could be anchored to the header. To delete header
>contents, you need code such as the following:
[quoted text clipped - 7 lines]
>Selection.Sections(1).Headers(wdHeaderFooterFirstPage) _
>.Range.Delete
Stefan Blom - 02 Aug 2006 10:15 GMT
To which paragraph(s) are the text boxes anchored?

Signature

Stefan Blom
Microsoft Word MVP

> Thanks Stefan for the message.
>
[quoted text clipped - 19 lines]
> >Selection.Sections(1).Headers(wdHeaderFooterFirstPage) _
> >.Range.Delete
Roderick O'Regan - 02 Aug 2006 10:46 GMT
They're anchored and locked to the first paragraph on the page.

>To which paragraph(s) are the text boxes anchored?
Stefan Blom - 02 Aug 2006 11:06 GMT
This is strange. If you want to, I could take a look at the document.
Email it to sbm01004@hotmail.com.

Signature

Stefan Blom
Microsoft Word MVP

> They're anchored and locked to the first paragraph on the page.
>
> >To which paragraph(s) are the text boxes anchored?
Roderick O'Regan - 02 Aug 2006 19:58 GMT
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

>This is strange. If you want to, I could take a look at the document.
>Email it to sbm01004@hotmail.com.
Stefan Blom - 03 Aug 2006 08:19 GMT
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!

Signature

Stefan Blom
Microsoft Word MVP

> Thanks for the offer Stefan but I might have resolved the problem.
>
[quoted text clipped - 30 lines]
> >This is strange. If you want to, I could take a look at the document.
> >Email it to sbm01004@hotmail.com.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.