locked
Need a way to check for section break in word RRS feed

  • Question

  • Hi

    How do I write VB codes to check if there is a section break (Next Page) in a line in a document?

    For example:

    |========== section break (Next Page)============

    where | denotes the cursor

    would appreciate any help.

    Thanks

     

     

     

    Friday, November 26, 2010 6:07 AM

Answers

  • Use the following code:

    Dim selstart As Range
    Dim strStart As String
    If Selection.Bookmarks("\line").Range.End = Selection.Sections(1).Range.End Then
        Set selstart = Selection.Bookmarks("\line").Range
        selstart.Collapse wdCollapseEnd
        Select Case selstart.PageSetup.SectionStart
            Case 0
                strStart = "Continuous Section "
            Case 1
                strStart = "New Column "
            Case 2
                strStart = "Next Page Section "
            Case 3
                strStart = "Even Page Section "
            Case Else
                strStart = "Odd Page Section"
        End Select
        MsgBox "The selection is located immediately before a " & strStart & "Break."
    Else
        MsgBox "The selecction is not located immediately before a break of any type"
    End If


    -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "mhard" wrote in message news:097e6b15-1715-46fd-8429-fab8b5c81dec@communitybridge.codeplex.com...

    Hi

    How do I write VB codes to check if there is a section break (Next Page) in a line in a document?

    For example:

    |========== section break (Next Page)============

    where | denotes the cursor

    would appreciate any help.

    Thanks


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    • Marked as answer by Jennifer Zhan Thursday, December 2, 2010 7:05 AM
    Friday, November 26, 2010 6:48 AM