Skipping Footnote error

A

acjharms

Weird automation problem:

In the document (W2K, WinXP) I'm working with, each paragraph has a
parenthetical at it's start. e.g.;

(A) The quick brown fox.....

I've written a macro to check the formatting of this text. I'm using
storyranges (the MVP page on this topic was quite helpful in that
regard) to get the text from the main story, text boxes, and footnotes
(the three areas said text could occur.) If I F8 through the macro all
ends well, but just running it, the text in footnotes is ignored. The
macro acknowledges that storyrange=wdfootnotestory and manipulates a
selection in the last paragraph in the Mainstory as if it were footnote
text. Text in textboxes is dealt with correctly. Any ideas? (I can
post relevant code, but it's not on this system so it won't be right
away).
 
A

acjharms

Weird automation problem:

In the document (W2K, WinXP) I'm working with, each paragraph has a
parenthetical at it's start. e.g.;

(A) The quick brown fox.....

I've written a macro to check the formatting of this text. I'm using
storyranges (the MVP page on this topic was quite helpful in that
regard) to get the text from the main story, text boxes, and footnotes
(the three areas said text could occur.) If I F8 through the macro all
ends well, but just running it, the text in footnotes is ignored. The
macro acknowledges that storyrange=wdfootnotestory and manipulates a
selection in the last paragraph in the Mainstory as if it were footnote
text. Text in textboxes is dealt with correctly. Any ideas? (I can
post relevant code, but it's not on this system so it won't be right
away).

the code in question (yes, all vars have ben declared)

clsttype(0) = 1 ' Mainstory
clsttype(1) = 2 ' Footnote
clsttype(2) = 5 ' Textbox

For Each strange In ActiveDocument.StoryRanges
Set clrange = strange
goodstory = False
For s = 0 To 2
If clrange.StoryType = clsttype(s) Then
goodstory = True
End If
Next
If goodstory Then
porfixing
Else
GoTo badstory
End If
While Not (strange.NextStoryRange Is Nothing)
Set strange = strange.NextStoryRange
Set clrange = strange
goodstory = False
For s = 0 To 2
If clrange.StoryType = clsttype(s) Then goodstory = True
Next
If goodstory Then
porfixing
Else
GoTo badstory
End If
Wend
badstory:
Next
......
.....
Public Sub porfixing()
For Each clapar In clrange.Paragraphs
Set portchk = clapar.Range
If portchk.StoryType = wdFootnotesStory Then
If Mid(portchk.Text, 3, 1) = "(" Then
portchk.Select'_____This is the problem line (works w/ F8,
otherwise selects incorrect text)
claspa = InStr(portchk.Text, ")")
If claspa = 0 Then GoTo woopse
Else
GoTo woopse 'no parenthetical
End If
Else
If Left(portchk.Text, 1) = "(" Then
portchk.Select
claspa = InStr(portchk.Text, ")")
If claspa = 0 Then GoTo 'no parenthetical
Else
GoTo woopse 'no parenthetical
End If
End If
If portchk.StoryType = wdFootnotesStory Then
Selection.MoveLeft
Selection.MoveRight Count:=2
Selection.MoveRight unit:=wdCharacter, Count:=claspa - 1,
Extend:=wdExtend
Else
Selection.MoveLeft
Selection.MoveRight unit:=wdCharacter, Count:=claspa + 1,
Extend:=wdExtend
End If
..
..
..
..
..
 
A

acjharms

NEVER MIND. I stepped away from the keyboard for a while, and when I
came back realized that storyranges weren't the problem, my use of
Selection was.
 

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