Thread: [Solved] For next fail
View Single Post
 
Old 10-07-2016, 03:59 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Adding this line, simply removes the formatting you have added, by replacing the range with what it was originally. What you should have is

Code:
Dim p As Paragraph 'Declare your variables
Dim Thistext As String
Dim meetssomecondition As Boolean

    For Each p In ActiveDocument.Paragraphs
        meetssomecondition = False 'Set the boolean value to false for each paragraph0
        Thistext = p.Range.Text 'Record the text content of the paragraph range
Debug.Print Thistext 
        If Left(Thistext, 5) = "Lorem" Then meetssomecondition = True 'add a condition relating to the text that will set the boolean value to True
        If meetssomecondition = True Then 'If that condition is met set the paragraph range to bold font
            p.Range.Font.Bold = True
        End If
    Next p
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote