Skip Section

G

gb0dms

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
 
D

Doug Robbins - Word MVP

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top