Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-03-2025, 05:20 AM
macropod's Avatar
macropod macropod is offline How to Detect Specific Page Breaks in Word VBA Windows 10 How to Detect Specific Page Breaks in Word VBA Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

For example:


Code:
Sub Demo()
Application.ScreenUpdating = False
Dim s As Long, Rng As Range
With ActiveDocument
  For s = .Sections.Count To 1 Step -1
    With .Sections(s)
      Set Rng = .Range: Rng.End = Rng.End - 1
      Rng.Find.Execute FindText:=Chr(12), Replacewith:="", Forward:=True, Wrap:=wdFindStop, Replace:=wdReplaceAll
      If s = 1 Then Exit Sub
      If .PageSetup.SectionStart <> wdSectionContinuous Then .Range.Characters.Last.Delete
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #2  
Old 01-03-2025, 05:31 AM
ADAL ADAL is offline How to Detect Specific Page Breaks in Word VBA Windows 10 How to Detect Specific Page Breaks in Word VBA Office 2021
Novice
How to Detect Specific Page Breaks in Word VBA
 
Join Date: Dec 2023
Posts: 26
ADAL is on a distinguished road
Default

Thanks, but I don't understand how that could help me in my case, maybe I didn't explain myself well, I want in the pages that there is a pagebreak of any type, that x is done and if there is no pagebreak of any type that y is done (even if there is a continuous sectionbreak on the page)
I tried this
Code:
Set rngPage= ActiveDocument.Bookmarks("\page").Range
If Len(rngPage.Text) - Len(Replace(rngPage.Text, Chr(12), "")) > 0 Then

but it also detects the continuous sectionbreaks
Reply With Quote
Reply

Tags
page breaks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Detect Specific Page Breaks in Word VBA 2 frustrating bugs in Word 2019 draft view - page number in status bar and invisible page breaks sidr Word 19 01-15-2025 03:23 PM
MS Word - can I automate page breaks after every 150 words??? ninose Word 4 09-05-2020 12:13 PM
How to Detect Specific Page Breaks in Word VBA Avoid continous breaks turn into page breaks sponge Word 3 09-14-2017 12:11 PM
How to Detect Specific Page Breaks in Word VBA Hidden page breaks and section breaks jrasicmark Word 3 06-02-2014 11:28 PM
Deleted Section Breaks Changes Page Breaks Brantnshellie Word 0 02-01-2009 09:22 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:17 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft