I have a document with a table in all of the headers except section 1. I
want to insert text into the table and skip seciton 1. I am having problems
skiping that section, I either error out becaus it is seaching for the table,
or it places the text into that header.

here is my code sofar

Sub Confidential()

Dim s As Section
Dim i As Integer
Application.ScreenUpdating = False

If ActiveWindow.ActivePane.View.SeekView <> wdSeekMainDocument Then
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End If

ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

For i = 2 To ActiveDocument.Sections.Count
Set sec = ActiveDocument.Sections(i)
With Selection
.Tables(1).Cell(1, 1).Select
With Selection
.Style = ActiveDocument.Styles("Confidential")
End With
.TypeText ("Confidential")
End With
If i = ActiveDocument.Sections.Count Then
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Selection.HomeKey wdStory
Else
ActiveWindow.ActivePane.View.NextHeaderFooter
End If
Next
Application.ScreenUpdating = True

End Sub

Re: Skip Section by Doug

Doug
Tue Aug 12 17:19:10 PDT 2008

Use:

Dim i As Long
With ActiveDocument
For i = 2 To .Sections.Count
With
.Sections(i).Headers(wdHeaderFooterPrimary).Range.Tables(1).Cell(1, 1).Range
.Text = "Confidential"
.Style = ActiveDocument.Styles("Confidential")
End With
Next i
End With


--
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

"gb0dms" <gb0dms@discussions.microsoft.com> wrote in message
news:5A8C185C-5AAE-43D7-A24E-E6E4295EA683@microsoft.com...
>I have a document with a table in all of the headers except section 1. I
> want to insert text into the table and skip seciton 1. I am having
> problems
> skiping that section, I either error out becaus it is seaching for the
> table,
> or it places the text into that header.
>
> here is my code sofar
>
> Sub Confidential()
>
> Dim s As Section
> Dim i As Integer
> Application.ScreenUpdating = False
>
> If ActiveWindow.ActivePane.View.SeekView <> wdSeekMainDocument Then
> ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
> End If
>
> ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
>
> For i = 2 To ActiveDocument.Sections.Count
> Set sec = ActiveDocument.Sections(i)
> With Selection
> .Tables(1).Cell(1, 1).Select
> With Selection
> .Style = ActiveDocument.Styles("Confidential")
> End With
> .TypeText ("Confidential")
> End With
> If i = ActiveDocument.Sections.Count Then
> ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
> Selection.HomeKey wdStory
> Else
> ActiveWindow.ActivePane.View.NextHeaderFooter
> End If
> Next
> Application.ScreenUpdating = True
>
> End Sub