![]() |
|
|
|
#1
|
|||
|
|||
|
Hi there!
I need a find/replace vba code to do that: Paragraph before: any text-Section Break Mark- Paragraph After: any text* *-Section Break Mark- Where * = paragraph mark The code should not replace when the paragraph contains only the section break mark. I will appreciate any help. Thanks in advance. Last edited by eduzs; 07-16-2020 at 04:31 AM. |
|
#2
|
|||
|
|||
|
Thanks all! This workaround works well for my need:
Code:
Dim x as long, oDoc as document, sTmp as string
Set oDoc = activedocument
For x = 1 To oDoc.Paragraphs.Count
sTmp = oDoc.Paragraphs(x).range.Text
If InStr(sTmp, Chr(12)) > 0 And Len(sTmp) > 2 Then
oDoc.Paragraphs(x).range.Select
With Selection
.Collapse direction:=wdCollapseEnd
.MoveLeft unit:=wdCharacter, Count:=1
.TypeText Chr(13) & Chr(13)
End With
End If
Next x
|
|
#3
|
|||
|
|||
|
How do I identify a section break instead of a page break as word identify all as chr(12)?
Breaks types: wdPageBreak wdColumnBreak wdSectionBreakNextPage wdSectionBreakContinuous wdSectionBreakEvenPage wdSectionBreakOddPage wdLineBreak wdLineBreakClearLeft wdLineBreakClearRight wdTextWrappingBreak How can I identify if there's a specific break in a selection? (e.g. wdSectionBreakNextPage) |
|
#4
|
||||
|
||||
|
Well for starters, if I wanted to know if there was a section break in my selection and if so, what type it was, I might try something like this.
Code:
Sub WhatIsIt()
Dim aRng As Range
If Selection.Sections.Count > 1 Then
MsgBox "Section Break Type: " & Selection.Sections.Last.PageSetup.SectionStart
Else
MsgBox "You don't have a section break there"
End If
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
#5
|
|||
|
|||
|
Thanks! This works to identify the presence of a certain break type.
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Word 2007, cannot insert Section Break (Continuous), only Section Break (Next Page)
|
btse1 | Word | 3 | 11-01-2018 09:23 AM |
| Section Break (Continuous) counted as Section Break (Next page) | wolfer | Word VBA | 2 | 01-06-2018 09:51 AM |
| Replacing paragraph formatting before column break also changes the next paragraph after the break | jjmartin1340 | Word | 3 | 09-21-2015 10:50 PM |
Section Break (Next Page) replaces Section Break (Continuous) when deleted
|
Carlabasson | Word | 2 | 03-25-2013 10:13 PM |
| URGENT: Mail 'Merge To New Doc' restarts paragraph numbering at each Section break | JamesF | Mail Merge | 0 | 07-28-2011 07:26 AM |