Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Selecting All Text in Header

1,931 views
Skip to first unread message

LA Lawyer

unread,
Mar 22, 2010, 7:21:48 PM3/22/10
to

I want to select everything (text and possibly even a text box) in a header.
How do I do that?


Doug Robbins - Word MVP

unread,
Mar 22, 2010, 6:48:40 PM3/22/10
to
ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Select

should do it as using

ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Delete

deletes everything, including a text box in the header.


--
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, originally posted via msnews.microsoft.com

"LA Lawyer" <hk...@kapplaw.com> wrote in message
news:#TYkT4gy...@TK2MSFTNGP02.phx.gbl...

Graham Mayor

unread,
Mar 23, 2010, 2:49:39 AM3/23/10
to
There are three headers (and three footers) associated with each section in
the document. Which header do you have in mind and what do you want to do
with the header having selected it?

The following will address all the headers in the document and assign them
in turn to the range named oRng. If you want to be more selected you can add
extra code to do that.

Dim oSection As Section
Dim oHeader As HeaderFooter
Dim oRng As Range
For Each oSection In ActiveDocument.Sections
For Each oHeader In oSection.Headers
Set oRng = oHeader.Range
'do what you want with oRng (the header) here e.g.
oRng.Delete
Next oHeader
Next oSection


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

"LA Lawyer" <hk...@kapplaw.com> wrote in message

news:%23TYkT4g...@TK2MSFTNGP02.phx.gbl...

iris b

unread,
Oct 27, 2011, 5:58:38 PM10/27/11
to
Hi Graham,

I have a problem that is similar to the above one... with a couple of changes:

I vave several sections in a document.

I want to delete all the footers from section 2 to the last section of the document....

I have tried and tried... with no luck... it doesn't work...

I will be very grateful if you can help me with this problem...
this is the code I have:

Sub try()
Dim sec As Section
Dim cnt As Integer
cnt = ActiveDocument.sections.Count

For Each sec In ActiveDocument.sections
WordBasic.ViewFooterOnly
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

Next

End Sub

this code only erases the footer of the first section and not the rest of them... this is exactly the oposit of what I need...
I need it to erase all the footers of sections 2 to the last section.

thank you

Iris

> On Monday, March 22, 2010 6:48 PM Doug Robbins - Word MVP wrote:

> ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Select
>
> should do it as using
>
> ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Delete
>
> deletes everything, including a text box in the header.
>
>
> --
> 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, originally posted via msnews.microsoft.com


>> On Monday, March 22, 2010 7:21 PM LA Lawyer wrote:

>> I want to select everything (text and possibly even a text box) in a header.
>> How do I do that?


Stefan Blom

unread,
Oct 28, 2011, 4:49:52 AM10/28/11
to
Unlink the sections and then delete the footers that you want to get rid of:

Sub UnlinkAndDelFooters()
Dim s As Section
Dim i As Long

If ActiveDocument.Sections.Count < 2 Then
Exit Sub 'do not run if only 1 section in doc
End If

For Each s In ActiveDocument.Sections
s.Footers(wdHeaderFooterEvenPages).LinkToPrevious = False
s.Footers(wdHeaderFooterFirstPage).LinkToPrevious = False
s.Footers(wdHeaderFooterPrimary).LinkToPrevious = False
Next s

For i = 2 To ActiveDocument.Sections.Count
ActiveDocument.Sections(i).Footers(wdHeaderFooterEvenPages).Range.Text = ""
ActiveDocument.Sections(i).Footers(wdHeaderFooterFirstPage).Range.Text = ""
ActiveDocument.Sections(i).Footers(wdHeaderFooterPrimary).Range.Text = ""
Next i
End Sub

--
Stefan Blom
Microsoft Word MVP




---------------------------------------------
"iris b" wrote in message news:2011102717...@terrranews.com...
0 new messages