troubleshooting Question

Changing type of section breaks in Word using VBA

Avatar of Andreas Hermle
Andreas HermleFlag for Germany asked on
Visual Basic ClassicMicrosoft Word
1 Comment1 Solution555 ViewsLast Modified:
I would like to change next-page section breaks into odd-page section breaks in Word using VBA. How come this code below does not work? I guess Word gets upset since the page numbering has to be rebuild completely, then?

Sub ChangeSecBrk()
Dim sec As Section
For Each sec In ActiveDocument.Sections
    If sec.PageSetup.SectionStart = wdSectionNextPage Then
        sec.PageSetup.SectionStart = wdSectionOddPage
    End If
Next sec
End Sub

Strangely enough, I tried to change "odd-page" section breaks into "next-page" section breaks using above VBA syntax (and adjusting the code) and the odd-page section breaks turned into continuous ones.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros