From: Pesach Shelnitz on
Hi Andreas,

The following macro will display the information that you want if you place
the cursor in the header. I don't know how to get all of this information in
a macro when
the cursor is in the main text.

Sub HeaderTypePageSection()
Dim hdType As String

With Selection
Select Case .Information(wdHeaderFooterType)
Case 1
If .Sections(1).PageSetup. _
DifferentFirstPageHeaderFooter Then
hdType = "odd"
Else
hdType = "primary"
End If
Case 3
hdType = "even"
Case 4
hdType = "first"
End Select
MsgBox "The current header is the " & hdType & _
" page header on Page " & _
.Information(wdActiveEndPageNumber) & _
" in Section " & _
.Information(wdActiveEndSectionNumber)
End With
End Sub

--
Hope this helps,
Pesach Shelnitz
My Web site: http://makeofficework.com


"andreas" wrote:

> On Dec 1, 2:43 pm, Pesach Shelnitz <pesach18(AT)hotmail.com> wrote:
> > Hi Andreas,
> >
> > The macro in my previous post removes frames only from the even-page header
> > in the current section and does not even look at the other headers. This is
> > done by setting a Range object equal to the Range object of the even-page
> > header. Of course, this code could be modified to do the same for all the
> > headers in the current section, or even in all sections. It is also possible
> > to add code that will pop up a message telling the user that a frame was
> > found in header X and ask for confirmation before removing it. Would you like
> > macros that do any of these things?
> >
> > --
> > Hope this helps,
> > Pesach Shelnitz
> > My Web site:http://makeofficework.com
> >
> >
> >
> > "andreas" wrote:
> > > On Dec 1, 12:27 pm, Pesach Shelnitz <pesach18(AT)hotmail.com> wrote:
> > > > Hi Andreas,
> >
> > > > The following macro will remove all frames from the header for even pages in
> > > > the current section. (The current section is the section in which the cursor
> > > > is located).
> >
> > > > Sub RemoveFrameFromCurrentEvenHeaderFooter()
> > > > Dim i As Long
> > > > Dim myRange As Range
> >
> > > > Set myRange = Selection.Sections(1).Headers(wdHeaderFooterEvenPages).Range
> > > > With myRange
> > > > For i = .Frames.Count To 1 Step -1
> > > > .Frames(i).Delete
> > > > Next
> > > > End With
> >
> > > > Set myRange = Nothing
> > > > End Sub
> >
> > > > --
> > > > Hope this helps,
> > > > Pesach Shelnitz
> > > > My Web site:http://makeofficework.com
> >
> > > > "andreas" wrote:
> > > > > Dear Experts:
> >
> > > > > For some specific reason I inserted a frame into the current even page
> > > > > header. How can I delete it via VBA on the condition that the cursor
> > > > > resides in the page (of the main document) whose header has got this
> > > > > frame?
> >
> > > > > Other headers, ie. odd page headers and first page header of the
> > > > > current section must not be deleted.
> > > > > Other headers in other sections may also have a frame in the header,
> > > > > but they must not be deleted, either.
> >
> > > > > Help is much appreciated. Thank you very much in advance.
> >
> > > > > Regards, Andreas
> >
> > > > > .- Hide quoted text -
> >
> > > > - Show quoted text -
> >
> > > Hi Pesach,
> >
> > > great, it is working just fine. Thank you very much for your terrific
> > > help.
> >
> > > There is one thing I would like to ask you:
> >
> > > From the main document I am not able to see whether the current header
> > > where the frame is located is a "First Page Header", "EvenPageHeader"
> > > or a "PrimaryPageHeader".
> > > I would have to access the header to find out.
> >
> > > Is it possible to rewrite the code so that REGARDLESS of the HEADER
> > > TYPE, the frame of the header of the current page is deleted?
> >
> > > I hope I could make myself clear and it is not too demanding.
> >
> > > Help is much appreciated. Thank you very much in advance. Regards,
> > > Andreas
> >
> > > .- Hide quoted text -
> >
> > - Show quoted text -
>
> Dear Pesach,
>
> thank you very much for your superb help. Actually there is one thing
> that would suffice:
>
> Macro code to tell me which is the current header (on the condition
> that my cursor is located in the main document and I select "View -
> Header-Footers" from the Main Menu):
> For example: the code should tell me that "... the current header is
> located on section x, adjusted page number x and is a primary or even
> or first page header".
>
> I hope this is not beyond the scope of this forum.
>
> Thank you very much in advance.
>
> Regards, Andreas
> .
>
From: andreas on
On Dec 1, 7:06 pm, Pesach Shelnitz <pesach18(AT)hotmail.com> wrote:
> Hi Andreas,
>
> The following macro will display the information that you want if you place
> the cursor in the header. I don't know how to get all of this information in
> a macro when
> the cursor is in the main text.
>
> Sub HeaderTypePageSection()
>     Dim hdType As String
>
>     With Selection
>         Select Case .Information(wdHeaderFooterType)
>             Case 1
>                 If .Sections(1).PageSetup. _
>                     DifferentFirstPageHeaderFooter Then
>                     hdType = "odd"
>                 Else
>                     hdType = "primary"
>                 End If
>             Case 3
>                 hdType = "even"
>             Case 4
>                 hdType = "first"
>         End Select
>         MsgBox "The current header is the " & hdType & _
>         " page header on Page " & _
>         .Information(wdActiveEndPageNumber) & _
>         " in Section " & _
>        .Information(wdActiveEndSectionNumber)
>     End With
> End Sub
>
> --
> Hope this helps,
> Pesach Shelnitz
> My Web site:http://makeofficework.com
>
>
>
> "andreas" wrote:
> > On Dec 1, 2:43 pm, Pesach Shelnitz <pesach18(AT)hotmail.com> wrote:
> > > Hi Andreas,
>
> > > The macro in my previous post removes frames only from the even-page header
> > > in the current section and does not even look at the other headers. This is
> > > done by setting a Range object equal to the Range object of the even-page
> > > header. Of course, this code could be modified to do the same for all the
> > > headers in the current section, or even in all sections. It is also possible
> > > to add code that will pop up a message telling the user that a frame was
> > > found in header X and ask for confirmation before removing it. Would you like
> > > macros that do any of these things?
>
> > > --
> > > Hope this helps,
> > > Pesach Shelnitz
> > > My Web site:http://makeofficework.com
>
> > > "andreas" wrote:
> > > > On Dec 1, 12:27 pm, Pesach Shelnitz <pesach18(AT)hotmail.com> wrote:
> > > > > Hi Andreas,
>
> > > > > The following macro will remove all frames from the header for even pages in
> > > > > the current section. (The current section is the section in which the cursor
> > > > > is located).
>
> > > > > Sub RemoveFrameFromCurrentEvenHeaderFooter()
> > > > >     Dim i As Long
> > > > >     Dim myRange As Range
>
> > > > >     Set myRange = Selection.Sections(1).Headers(wdHeaderFooterEvenPages).Range
> > > > >     With myRange
> > > > >         For i = .Frames.Count To 1 Step -1
> > > > >            .Frames(i).Delete
> > > > >         Next
> > > > >     End With
>
> > > > >     Set myRange = Nothing
> > > > > End Sub
>
> > > > > --
> > > > > Hope this helps,
> > > > > Pesach Shelnitz
> > > > > My Web site:http://makeofficework.com
>
> > > > > "andreas" wrote:
> > > > > > Dear Experts:
>
> > > > > > For some specific reason I inserted a frame into the current even page
> > > > > > header. How can I delete it via VBA on the condition that the cursor
> > > > > > resides in the page (of the main document) whose header has got this
> > > > > > frame?
>
> > > > > > Other headers, ie. odd page headers and first page header of the
> > > > > > current section must not be deleted.
> > > > > > Other headers in other sections may also have a frame in the header,
> > > > > > but they must not be deleted, either.
>
> > > > > > Help is much appreciated. Thank you very much in advance.
>
> > > > > > Regards, Andreas
>
> > > > > > .- Hide quoted text -
>
> > > > > - Show quoted text -
>
> > > > Hi Pesach,
>
> > > > great, it is working just fine. Thank you very much for your terrific
> > > > help.
>
> > > > There is one thing I would like to ask you:
>
> > > > From the main document I am not able to see whether the current header
> > > > where the frame is located is a "First Page Header", "EvenPageHeader"
> > > > or a "PrimaryPageHeader".
> > > > I would have to access the header to find out.
>
> > > > Is it possible to rewrite the code so that REGARDLESS of the HEADER
> > > > TYPE, the frame of the header of the current page is deleted?
>
> > > > I hope I could make  myself clear and it is not too demanding.
>
> > > > Help is much appreciated. Thank you very much in advance. Regards,
> > > > Andreas
>
> > > > .- Hide quoted text -
>
> > > - Show quoted text -
>
> > Dear Pesach,
>
> > thank you very much for your superb help. Actually there is one thing
> > that would suffice:
>
> > Macro code to tell me which is the current header (on the condition
> > that my cursor is located in the main document and I select "View -
> > Header-Footers" from the Main Menu):
> > For example: the code should tell me that "... the current header is
> > located on section x, adjusted page number x and is a primary or even
> > or first page header".
>
> > I hope this is not beyond the scope of this forum.
>
> > Thank you very much in advance.
>
> > Regards, Andreas
> > .- Hide quoted text -
>
> - Show quoted text -

Hi Pesach,

thank you very much for your swift help. I just tried it out.
Everything is working fine with the exception of the "Even header"
case.
In that case the message box does not list "even" but nothing. For the
trial I chose the following Section Page Set up:

- Different First Page Header and Different Even/Odd Page Headers

Any idea why this is so.

Thank you again.

Regards, Andreas
From: Pesach Shelnitz on
Hi Andreas,

I mixed up a bit. Here is a corrected version of the macro.

Sub HeaderTypePageSection()
Dim hdType As String

With Selection
Select Case .Information(wdHeaderFooterType)
Case 0
hdType = "even"
Case 1
If .Sections(1).PageSetup. _
OddAndEvenPagesHeaderFooter Then
hdType = "odd"
Else
hdType = "primary"
End If
Case 4
hdType = "first"
Case Else
MsgBox "The cursor is not in a header."
Exit Sub
End Select
MsgBox "The current header is the " & hdType & _
" page header on Page " & _
.Information(wdActiveEndPageNumber) & _
" in Section " & _
.Information(wdActiveEndSectionNumber)
End With
End Sub

--
Hope this helps,
Pesach Shelnitz
My Web site: http://makeofficework.com


"andreas" wrote:

> On Dec 1, 7:06 pm, Pesach Shelnitz <pesach18(AT)hotmail.com> wrote:
> > Hi Andreas,
> >
> > The following macro will display the information that you want if you place
> > the cursor in the header. I don't know how to get all of this information in
> > a macro when
> > the cursor is in the main text.
> >
> > Sub HeaderTypePageSection()
> > Dim hdType As String
> >
> > With Selection
> > Select Case .Information(wdHeaderFooterType)
> > Case 1
> > If .Sections(1).PageSetup. _
> > DifferentFirstPageHeaderFooter Then
> > hdType = "odd"
> > Else
> > hdType = "primary"
> > End If
> > Case 3
> > hdType = "even"
> > Case 4
> > hdType = "first"
> > End Select
> > MsgBox "The current header is the " & hdType & _
> > " page header on Page " & _
> > .Information(wdActiveEndPageNumber) & _
> > " in Section " & _
> > .Information(wdActiveEndSectionNumber)
> > End With
> > End Sub
> >
> > --
> > Hope this helps,
> > Pesach Shelnitz
> > My Web site:http://makeofficework.com
> >
> >
> >
> > "andreas" wrote:
> > > On Dec 1, 2:43 pm, Pesach Shelnitz <pesach18(AT)hotmail.com> wrote:
> > > > Hi Andreas,
> >
> > > > The macro in my previous post removes frames only from the even-page header
> > > > in the current section and does not even look at the other headers. This is
> > > > done by setting a Range object equal to the Range object of the even-page
> > > > header. Of course, this code could be modified to do the same for all the
> > > > headers in the current section, or even in all sections. It is also possible
> > > > to add code that will pop up a message telling the user that a frame was
> > > > found in header X and ask for confirmation before removing it. Would you like
> > > > macros that do any of these things?
> >
> > > > --
> > > > Hope this helps,
> > > > Pesach Shelnitz
> > > > My Web site:http://makeofficework.com
> >
> > > > "andreas" wrote:
> > > > > On Dec 1, 12:27 pm, Pesach Shelnitz <pesach18(AT)hotmail.com> wrote:
> > > > > > Hi Andreas,
> >
> > > > > > The following macro will remove all frames from the header for even pages in
> > > > > > the current section. (The current section is the section in which the cursor
> > > > > > is located).
> >
> > > > > > Sub RemoveFrameFromCurrentEvenHeaderFooter()
> > > > > > Dim i As Long
> > > > > > Dim myRange As Range
> >
> > > > > > Set myRange = Selection.Sections(1).Headers(wdHeaderFooterEvenPages).Range
> > > > > > With myRange
> > > > > > For i = .Frames.Count To 1 Step -1
> > > > > > .Frames(i).Delete
> > > > > > Next
> > > > > > End With
> >
> > > > > > Set myRange = Nothing
> > > > > > End Sub
> >
> > > > > > --
> > > > > > Hope this helps,
> > > > > > Pesach Shelnitz
> > > > > > My Web site:http://makeofficework.com
> >
> > > > > > "andreas" wrote:
> > > > > > > Dear Experts:
> >
> > > > > > > For some specific reason I inserted a frame into the current even page
> > > > > > > header. How can I delete it via VBA on the condition that the cursor
> > > > > > > resides in the page (of the main document) whose header has got this
> > > > > > > frame?
> >
> > > > > > > Other headers, ie. odd page headers and first page header of the
> > > > > > > current section must not be deleted.
> > > > > > > Other headers in other sections may also have a frame in the header,
> > > > > > > but they must not be deleted, either.
> >
> > > > > > > Help is much appreciated. Thank you very much in advance.
> >
> > > > > > > Regards, Andreas
> >
> > > > > > > .- Hide quoted text -
> >
> > > > > > - Show quoted text -
> >
> > > > > Hi Pesach,
> >
> > > > > great, it is working just fine. Thank you very much for your terrific
> > > > > help.
> >
> > > > > There is one thing I would like to ask you:
> >
> > > > > From the main document I am not able to see whether the current header
> > > > > where the frame is located is a "First Page Header", "EvenPageHeader"
> > > > > or a "PrimaryPageHeader".
> > > > > I would have to access the header to find out.
> >
> > > > > Is it possible to rewrite the code so that REGARDLESS of the HEADER
> > > > > TYPE, the frame of the header of the current page is deleted?
> >
> > > > > I hope I could make myself clear and it is not too demanding.
> >
> > > > > Help is much appreciated. Thank you very much in advance. Regards,
> > > > > Andreas
> >
> > > > > .- Hide quoted text -
> >
> > > > - Show quoted text -
> >
> > > Dear Pesach,
> >
> > > thank you very much for your superb help. Actually there is one thing
> > > that would suffice:
> >
> > > Macro code to tell me which is the current header (on the condition
> > > that my cursor is located in the main document and I select "View -
> > > Header-Footers" from the Main Menu):
> > > For example: the code should tell me that "... the current header is
> > > located on section x, adjusted page number x and is a primary or even
> > > or first page header".
> >
> > > I hope this is not beyond the scope of this forum.
> >
> > > Thank you very much in advance.
> >
> > > Regards, Andreas
> > > .- Hide quoted text -
> >
> > - Show quoted text -
>
> Hi Pesach,
>
> thank you very much for your swift help. I just tried it out.
> Everything is working fine with the exception of the "Even header"
> case.
> In that case the message box does not list "even" but nothing. For the
> trial I chose the following Section Page Set up:
>
> - Different First Page Header and Different Even/Odd Page Headers
>
> Any idea why this is so.
>
> Thank you again.
>
> Regards, Andreas
> .
>
From: andreas on
On Dec 1, 9:58 pm, Pesach Shelnitz <pesach18(AT)hotmail.com> wrote:
> Hi Andreas,
>
> I mixed up a bit. Here is a corrected version of the macro.
>
> Sub HeaderTypePageSection()
>     Dim hdType As String
>
>     With Selection
>         Select Case .Information(wdHeaderFooterType)
>             Case 0
>                 hdType = "even"
>             Case 1
>                 If .Sections(1).PageSetup. _
>                     OddAndEvenPagesHeaderFooter Then
>                     hdType = "odd"
>                 Else
>                     hdType = "primary"
>                 End If
>             Case 4
>                 hdType = "first"
>             Case Else
>                 MsgBox "The cursor is not in a header."
>                 Exit Sub
>         End Select
>         MsgBox "The current header is the " & hdType & _
>         " page header on Page " & _
>         .Information(wdActiveEndPageNumber) & _
>         " in Section " & _
>        .Information(wdActiveEndSectionNumber)
>     End With
> End Sub
>
> --
> Hope this helps,
> Pesach Shelnitz
> My Web site:http://makeofficework.com
>
>
>
> "andreas" wrote:
> > On Dec 1, 7:06 pm, Pesach Shelnitz <pesach18(AT)hotmail.com> wrote:
> > > Hi Andreas,
>
> > > The following macro will display the information that you want if you place
> > > the cursor in the header. I don't know how to get all of this information in
> > > a macro when
> > > the cursor is in the main text.
>
> > > Sub HeaderTypePageSection()
> > >     Dim hdType As String
>
> > >     With Selection
> > >         Select Case .Information(wdHeaderFooterType)
> > >             Case 1
> > >                 If .Sections(1).PageSetup. _
> > >                     DifferentFirstPageHeaderFooter Then
> > >                     hdType = "odd"
> > >                 Else
> > >                     hdType = "primary"
> > >                 End If
> > >             Case 3
> > >                 hdType = "even"
> > >             Case 4
> > >                 hdType = "first"
> > >         End Select
> > >         MsgBox "The current header is the " & hdType & _
> > >         " page header on Page " & _
> > >         .Information(wdActiveEndPageNumber) & _
> > >         " in Section " & _
> > >        .Information(wdActiveEndSectionNumber)
> > >     End With
> > > End Sub
>
> > > --
> > > Hope this helps,
> > > Pesach Shelnitz
> > > My Web site:http://makeofficework.com
>
> > > "andreas" wrote:
> > > > On Dec 1, 2:43 pm, Pesach Shelnitz <pesach18(AT)hotmail.com> wrote:
> > > > > Hi Andreas,
>
> > > > > The macro in my previous post removes frames only from the even-page header
> > > > > in the current section and does not even look at the other headers. This is
> > > > > done by setting a Range object equal to the Range object of the even-page
> > > > > header. Of course, this code could be modified to do the same for all the
> > > > > headers in the current section, or even in all sections. It is also possible
> > > > > to add code that will pop up a message telling the user that a frame was
> > > > > found in header X and ask for confirmation before removing it. Would you like
> > > > > macros that do any of these things?
>
> > > > > --
> > > > > Hope this helps,
> > > > > Pesach Shelnitz
> > > > > My Web site:http://makeofficework.com
>
> > > > > "andreas" wrote:
> > > > > > On Dec 1, 12:27 pm, Pesach Shelnitz <pesach18(AT)hotmail.com> wrote:
> > > > > > > Hi Andreas,
>
> > > > > > > The following macro will remove all frames from the header for even pages in
> > > > > > > the current section. (The current section is the section in which the cursor
> > > > > > > is located).
>
> > > > > > > Sub RemoveFrameFromCurrentEvenHeaderFooter()
> > > > > > >     Dim i As Long
> > > > > > >     Dim myRange As Range
>
> > > > > > >     Set myRange = Selection.Sections(1).Headers(wdHeaderFooterEvenPages).Range
> > > > > > >     With myRange
> > > > > > >         For i = .Frames.Count To 1 Step -1
> > > > > > >            .Frames(i).Delete
> > > > > > >         Next
> > > > > > >     End With
>
> > > > > > >     Set myRange = Nothing
> > > > > > > End Sub
>
> > > > > > > --
> > > > > > > Hope this helps,
> > > > > > > Pesach Shelnitz
> > > > > > > My Web site:http://makeofficework.com
>
> > > > > > > "andreas" wrote:
> > > > > > > > Dear Experts:
>
> > > > > > > > For some specific reason I inserted a frame into the current even page
> > > > > > > > header. How can I delete it via VBA on the condition that the cursor
> > > > > > > > resides in the page (of the main document) whose header has got this
> > > > > > > > frame?
>
> > > > > > > > Other headers, ie. odd page headers and first page header of the
> > > > > > > > current section must not be deleted.
> > > > > > > > Other headers in other sections may also have a frame in the header,
> > > > > > > > but they must not be deleted, either.
>
> > > > > > > > Help is much appreciated. Thank you very much in advance.
>
> > > > > > > > Regards, Andreas
>
> > > > > > > > .- Hide quoted text -
>
> > > > > > > - Show quoted text -
>
> > > > > > Hi Pesach,
>
> > > > > > great, it is working just fine. Thank you very much for your terrific
> > > > > > help.
>
> > > > > > There is one thing I would like to ask you:
>
> > > > > > From the main document I am not able to see whether the current header
> > > > > > where the frame is located is a "First Page Header", "EvenPageHeader"
> > > > > > or a "PrimaryPageHeader".
> > > > > > I would have to access the header to find out.
>
> > > > > > Is it possible to rewrite the code so that REGARDLESS of the HEADER
> > > > > > TYPE, the frame of the header of the current page is deleted?
>
> > > > > > I hope I could make  myself clear and it is not too demanding..
>
> > > > > > Help is much appreciated. Thank you very much in advance. Regards,
> > > > > > Andreas
>
> > > > > > .- Hide quoted text -
>
> > > > > - Show quoted text -
>
> > > > Dear Pesach,
>
> > > > thank you very much for your superb help. Actually there is one thing
> > > > that would suffice:
>
> > > > Macro code to tell me which is the current header (on the condition
> > > > that my cursor is located in the main document and I select "View -
> > > > Header-Footers" from the Main Menu):
> > > > For example: the code should tell me that "... the current header is
> > > > located on section x, adjusted page number x and is a primary or even
> > > > or first page header".
>
> > > > I hope this is not beyond the scope of this forum.
>
> > > > Thank you very much in advance.
>
> > > > Regards, Andreas
> > > > .- Hide quoted text -
>
> > > - Show quoted text -
>
> > Hi Pesach,
>
> > thank you very much for  your swift help. I just tried it out.
> > Everything is working fine with the exception of the "Even header"
> > case.
> > In that case the message box does not list "even" but nothing. For the
> > trial I chose the following Section Page Set up:
>
> > - Different First Page Header and Different Even/Odd Page Headers
>
> > Any idea why this is so.
>
> > Thank you again.
>
> > Regards, Andreas
> > .- Hide quoted text -
>
> - Show quoted text -

Hi Pesach,

that's it. Thank you very much for your professional help. I really
appreciate it. Regards, Andreas