#1
|
|||
|
|||
For next fail
Kind of curious why this never moves to Next Paragraph ? If line <<<<< is remmed out it does, but still has me baffled. Code:
For Each p In ActiveDocument.Paragraphs Thistext = p.Range.Text Debug.Print Thistext If meetssomecondition = True Then p.Range.Font.Bold = True p.Range.Text = Thistext <<<<< End If Next |
#2
|
||||
|
||||
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 |
#3
|
|||
|
|||
Thanks very much for the correction, which I'll have a play with.
I'm still not sure why the failure... even if the original range was restored the code instruction 'Next' would still be executed (you'd think). |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Insert File Printout w/ PDF fail | jsilvoy | OneNote | 0 | 03-05-2015 06:44 PM |
Fail to insert “table of content”, | Jamal NUMAN | Word | 7 | 11-16-2013 01:21 AM |
Big presentation, links fail: solution | theredspecial | PowerPoint | 6 | 08-26-2013 10:35 PM |
Office repair fail | markg2 | Office | 1 | 08-18-2013 07:23 AM |
Shortcuts Fail | sussertown | Outlook | 0 | 02-16-2009 06:38 PM |