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