PDA

View Full Version : add text after second word after fullfill condition



dagerr
11-09-2018, 03:03 AM
Hi, I need a code which add text after second word after fullfill condition but the syntax: oPara.Font.Size = 9 is not working, please, write me correct




Sub add_after_xml()


Dim oPara As Paragraph
For Each oPara In ActiveDocument.Paragraphs

If Len(oPara.Range.Text) > 1 And oPara.Font.Size = 9 Then
With oPara.Range.Words(2)
.InsertAfter "</Bold:bb>"
.Collapse 0
End With


End If



Next oPara
End Sub



Cheers

gmaxey
11-09-2018, 05:09 PM
If Len(oPara.Range.Text) > 1 And oPara.Range.Font.Size = 9 Then

dagerr
11-16-2018, 12:56 AM
Ok, it works, but only when paragraph include only two words, My goal is to insert text before and after bold is end. So above code is completely wrong.


Here is example what should it do:
"<Bold:bb>Lorem ipsum </Bold:bb> dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
<Bold:bb>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </Bold:bb>
<Bold:bb>Duis aute irure dolor in reprehenderit in voluptate velit esse </Bold:bb>cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."


I have no idea how to handle it.