E
Ed
I need a routine to determine the presence of text in the various "stories"
in my document. If text is present, I work on the text. If no text is
present, I can skip processing in the story.
In particular (and where the below routine seems to fall apart), I want to
see if a header contains text. The below works fine if there is header text
in Section 1 of the document, but if there is no header text in sections 1
and 2, but there is header text section 3, the routine won't find it. (The
MakeHFValid routine is used, although not reprinted, to overcome the problem
when a story is blank. Does this code make sense to anyone, and if so, can
you tell me why header text in section3 does not return 'positive'? (No
even/odd page headers; no firstpage headers, etc. Just plain stuff) Thanks.
Ed
For Each osection In ActiveDocument.Sections
For Each astory In ActiveDocument.StoryRanges
MakeHFValid
aval = astory.Text
atype = astory.StoryType
If Len(aval) = 1 Then
aval = Asc(aval)
End If
If astory.StoryType = wdFootnotesStory Then
If InStr(InStory, "FNotes") = 0 And aval <> 13 Then InStory=
InStory+ "FNotes" ' the "If Instr(InStory,"FNotes") = 0" is just to
prevent a second entry of the same thing.
ElseIf astory.StoryType = wdEndnotesStory Then
If InStr(InStory, "ENotes") = 0 And aval <> 13 Then InStory=
InStory+ "ENotes"
ElseIf astory.StoryType = wdCommentsStory Then
If InStr(InStory, "Comments") = 0 And aval <> 13 Then InStory=
InStory+ "Comments"
ElseIf astory.StoryType = wdTextFrameStory Then
If InStr(InStory, "TextBox") = 0 And aval <> 13 Then InStory=
InStory+ "TextBox"
ElseIf astory.StoryType = wdEvenPagesHeaderStory Then
If InStr(InStory, "EPHead") = 0 And aval <> 13 Then InStory=
InStory+ "EPHead"
ElseIf astory.StoryType = wdPrimaryHeaderStory Then
If InStr(InStory, "Header") = 0 And aval <> 13 Then InStory=
InStory+ "Header"
ElseIf astory.StoryType = wdEvenPagesFooterStory Then
If InStr(InStory, "EPFoot") = 0 And aval <> 13 Then InStory=
InStory+ "EPFoot"
ElseIf astory.StoryType = wdPrimaryFooterStory Then
If InStr(InStory, "Footer") = 0 And aval <> 13 Then InStory=
InStory+ "Footer"
ElseIf astory.StoryType = wdFirstPageFooterStory Then
If InStr(InStory, "FPFoot") = 0 And aval <> 13 Then InStory=
InStory+ "FPFoot"
ElseIf astory.StoryType = wdFirstPageHeaderStory Then
If InStr(InStory, "FPHead") = 0 And aval <> 13 Then InStory=
InStory+ "FPHead"
End If
Next aStory
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
Next oSection
in my document. If text is present, I work on the text. If no text is
present, I can skip processing in the story.
In particular (and where the below routine seems to fall apart), I want to
see if a header contains text. The below works fine if there is header text
in Section 1 of the document, but if there is no header text in sections 1
and 2, but there is header text section 3, the routine won't find it. (The
MakeHFValid routine is used, although not reprinted, to overcome the problem
when a story is blank. Does this code make sense to anyone, and if so, can
you tell me why header text in section3 does not return 'positive'? (No
even/odd page headers; no firstpage headers, etc. Just plain stuff) Thanks.
Ed
For Each osection In ActiveDocument.Sections
For Each astory In ActiveDocument.StoryRanges
MakeHFValid
aval = astory.Text
atype = astory.StoryType
If Len(aval) = 1 Then
aval = Asc(aval)
End If
If astory.StoryType = wdFootnotesStory Then
If InStr(InStory, "FNotes") = 0 And aval <> 13 Then InStory=
InStory+ "FNotes" ' the "If Instr(InStory,"FNotes") = 0" is just to
prevent a second entry of the same thing.
ElseIf astory.StoryType = wdEndnotesStory Then
If InStr(InStory, "ENotes") = 0 And aval <> 13 Then InStory=
InStory+ "ENotes"
ElseIf astory.StoryType = wdCommentsStory Then
If InStr(InStory, "Comments") = 0 And aval <> 13 Then InStory=
InStory+ "Comments"
ElseIf astory.StoryType = wdTextFrameStory Then
If InStr(InStory, "TextBox") = 0 And aval <> 13 Then InStory=
InStory+ "TextBox"
ElseIf astory.StoryType = wdEvenPagesHeaderStory Then
If InStr(InStory, "EPHead") = 0 And aval <> 13 Then InStory=
InStory+ "EPHead"
ElseIf astory.StoryType = wdPrimaryHeaderStory Then
If InStr(InStory, "Header") = 0 And aval <> 13 Then InStory=
InStory+ "Header"
ElseIf astory.StoryType = wdEvenPagesFooterStory Then
If InStr(InStory, "EPFoot") = 0 And aval <> 13 Then InStory=
InStory+ "EPFoot"
ElseIf astory.StoryType = wdPrimaryFooterStory Then
If InStr(InStory, "Footer") = 0 And aval <> 13 Then InStory=
InStory+ "Footer"
ElseIf astory.StoryType = wdFirstPageFooterStory Then
If InStr(InStory, "FPFoot") = 0 And aval <> 13 Then InStory=
InStory+ "FPFoot"
ElseIf astory.StoryType = wdFirstPageHeaderStory Then
If InStr(InStory, "FPHead") = 0 And aval <> 13 Then InStory=
InStory+ "FPHead"
End If
Next aStory
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
Next oSection