Hi there,
Would you please let me know what I'm dong wrong in this code?
I want to delete "Page {PAGE}" in the first page header if different First
page option is checked off. Any help would be appreciated!
-------------------------
Sub Delete1stPgNo()
Dim oField As Field
If ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True Then
ActiveDocument.ActiveWindow.ActivePane.View.SeekView =
wdSeekFirstPageHeader
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Page"
.Replacement.Text = ""
End With
With Selection.Range.Fields
If oField.Type = wdFieldPage Then
oField.Delete
End If
End With
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Without using a "Different first page" header, there is no way to omit a
page number from the first page (unless you are using Insert | Page Numbers
and clear the check box for "Show number on first page," and there's no
telling what kind of MS-written code is behind this feature). Actually, if
this is the first page of a document and not just a section, and if the
first page is numbered one, you could use a conditional field:
{ IF { PAGE } > 1 { PAGE } }
--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
"Leila" <Leila@discussions.microsoft.com> wrote in message
news:D5B9C9BC-3838-4100-AB36-2FA0FD36EBA4@microsoft.com...
> Hi there,
> Would you please let me know what I'm dong wrong in this code?
> I want to delete "Page {PAGE}" in the first page header if different First
> page option is checked off. Any help would be appreciated!
> -------------------------
> Sub Delete1stPgNo()
>
> Dim oField As Field
> If ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True Then
>
> ActiveDocument.ActiveWindow.ActivePane.View.SeekView =
> wdSeekFirstPageHeader
> Selection.Find.ClearFormatting
> With Selection.Find
> .Text = "Page"
> .Replacement.Text = ""
> End With
> With Selection.Range.Fields
> If oField.Type = wdFieldPage Then
> oField.Delete
>
> End If
> End With
> ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
>
> End If
>
> End Sub
>
>
>
>
Thanks so much Suzanne, your solution worked perfectly for the problem.
Leila
"Suzanne S. Barnhill" wrote:
> Without using a "Different first page" header, there is no way to omit a
> page number from the first page (unless you are using Insert | Page Numbers
> and clear the check box for "Show number on first page," and there's no
> telling what kind of MS-written code is behind this feature). Actually, if
> this is the first page of a document and not just a section, and if the
> first page is numbered one, you could use a conditional field:
>
> { IF { PAGE } > 1 { PAGE } }
>
> --
> Suzanne S. Barnhill
> Microsoft MVP (Word)
> Words into Type
> Fairhope, Alabama USA
> Word MVP FAQ site: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> all may benefit.
>
> "Leila" <Leila@discussions.microsoft.com> wrote in message
> news:D5B9C9BC-3838-4100-AB36-2FA0FD36EBA4@microsoft.com...
> > Hi there,
> > Would you please let me know what I'm dong wrong in this code?
> > I want to delete "Page {PAGE}" in the first page header if different First
> > page option is checked off. Any help would be appreciated!
> > -------------------------
> > Sub Delete1stPgNo()
> >
> > Dim oField As Field
> > If ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True Then
> >
> > ActiveDocument.ActiveWindow.ActivePane.View.SeekView =
> > wdSeekFirstPageHeader
> > Selection.Find.ClearFormatting
> > With Selection.Find
> > .Text = "Page"
> > .Replacement.Text = ""
> > End With
> > With Selection.Range.Fields
> > If oField.Type = wdFieldPage Then
> > oField.Delete
> >
> > End If
> > End With
> > ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
> >
> > End If
> >
> > End Sub
> >
> >
> >
> >
>
>
Just one more question how can I put the text "page" in this field? may thanks
"Leila" wrote:
> Thanks so much Suzanne, your solution worked perfectly for the problem.
> Leila
>
> "Suzanne S. Barnhill" wrote:
>
> > Without using a "Different first page" header, there is no way to omit a
> > page number from the first page (unless you are using Insert | Page Numbers
> > and clear the check box for "Show number on first page," and there's no
> > telling what kind of MS-written code is behind this feature). Actually, if
> > this is the first page of a document and not just a section, and if the
> > first page is numbered one, you could use a conditional field:
> >
> > { IF { PAGE } > 1 { PAGE } }
> >
> > --
> > Suzanne S. Barnhill
> > Microsoft MVP (Word)
> > Words into Type
> > Fairhope, Alabama USA
> > Word MVP FAQ site: http://word.mvps.org
> > Email cannot be acknowledged; please post all follow-ups to the newsgroup so
> > all may benefit.
> >
> > "Leila" <Leila@discussions.microsoft.com> wrote in message
> > news:D5B9C9BC-3838-4100-AB36-2FA0FD36EBA4@microsoft.com...
> > > Hi there,
> > > Would you please let me know what I'm dong wrong in this code?
> > > I want to delete "Page {PAGE}" in the first page header if different First
> > > page option is checked off. Any help would be appreciated!
> > > -------------------------
> > > Sub Delete1stPgNo()
> > >
> > > Dim oField As Field
> > > If ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = True Then
> > >
> > > ActiveDocument.ActiveWindow.ActivePane.View.SeekView =
> > > wdSeekFirstPageHeader
> > > Selection.Find.ClearFormatting
> > > With Selection.Find
> > > .Text = "Page"
> > > .Replacement.Text = ""
> > > End With
> > > With Selection.Range.Fields
> > > If oField.Type = wdFieldPage Then
> > > oField.Delete
> > >
> > > End If
> > > End With
> > > ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
> > >
> > > End If
> > >
> > > End Sub
> > >
> > >
> > >
> > >
> >
> >
--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
"Leila" <Leila@discussions.microsoft.com> wrote in message
news:C0F61A16-EF02-451D-B4BA-D9C6CFCFEC34@microsoft.com...
> Just one more question how can I put the text "page" in this field? may
thanks
>
> "Leila" wrote:
>
> > Thanks so much Suzanne, your solution worked perfectly for the problem.
> > Leila
> >
> > "Suzanne S. Barnhill" wrote:
> >
> > > Without using a "Different first page" header, there is no way to omit
a
> > > page number from the first page (unless you are using Insert | Page
Numbers
> > > and clear the check box for "Show number on first page," and there's
no
> > > telling what kind of MS-written code is behind this feature).
Actually, if
> > > this is the first page of a document and not just a section, and if
the
> > > first page is numbered one, you could use a conditional field:
> > >
> > > { IF { PAGE } > 1 { PAGE } }
> > >
> > > --
> > > Suzanne S. Barnhill
> > > Microsoft MVP (Word)
> > > Words into Type
> > > Fairhope, Alabama USA
> > > Word MVP FAQ site: http://word.mvps.org
> > > Email cannot be acknowledged; please post all follow-ups to the
newsgroup so
> > > all may benefit.
> > >
> > > "Leila" <Leila@discussions.microsoft.com> wrote in message
> > > news:D5B9C9BC-3838-4100-AB36-2FA0FD36EBA4@microsoft.com...
> > > > Hi there,
> > > > Would you please let me know what I'm dong wrong in this code?
> > > > I want to delete "Page {PAGE}" in the first page header if different
First
> > > > page option is checked off. Any help would be appreciated!
> > > > -------------------------
> > > > Sub Delete1stPgNo()
> > > >
> > > > Dim oField As Field
> > > > If ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter =
True Then
> > > >
> > > > ActiveDocument.ActiveWindow.ActivePane.View.SeekView =
> > > > wdSeekFirstPageHeader
> > > > Selection.Find.ClearFormatting
> > > > With Selection.Find
> > > > .Text = "Page"
> > > > .Replacement.Text = ""
> > > > End With
> > > > With Selection.Range.Fields
> > > > If oField.Type = wdFieldPage Then
> > > > oField.Delete
> > > >
> > > > End If
> > > > End With
> > > > ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
> > > >
> > > > End If
> > > >
> > > > End Sub
> > > >
> > > >
> > > >
> > > >
> > >
> > >