Repeat code for each word document section section

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Josha
    New Member
    • Sep 2006
    • 4

    #1

    Repeat code for each word document section section

    Hi,

    I am new to VB and still getting a handle on things. How do I repeat the below code for each new odd numbered page. If this requires the use of line numbers instead of paragraph numbers to set the range, remark in code.

    Josha

    Code:
    Sub Test3()
    
    Dim pChar As Variant
    Set myDoc = ActiveDocument
    
    'The following example creates a Range object beginning at the start
    'of the second paragraph and ending after the third paragraph.
    'The corresponding line numbers that need to be used are ln10 to ln15.
    'The code must be repeated for each odd numbered page.
    Set myRange = myDoc.Range(Start:=myDoc.Paragraphs(2).Range.Start, _
        End:=myDoc.Paragraphs(5).Range.End)
        
      
        For Each pChar In myRange.Characters
            If pChar Like "[A-Z]" Then
            pChar.Select
            Selection.Range.Case = wdTitleWord
            End If
        Next
    
    
    End Sub
Working...