![]() |
|
#16
|
|||
|
|||
|
Don't get rid of it completely. There are times that it must be used. See Learn to love ranges at:
VBA Basics |
|
#17
|
|||
|
|||
|
Thank you, Gmaxey! I will certainly study that article. But for the time being here's another difficulty:
Code:
Dim aRng As Range
For Each Paragraph In ActiveDocument.Paragraphs
NrPara = NoPara + 1
Set aRng = ActiveDocument.Paragraphs(NrPara).Range
If Paragraph.Range.ParagraphFormat.Alignment = wdAlignParagraphRight _
Or Paragraph.Range.ParagraphFormat.LeftIndent > 30 Then
aRng.Format.Font.Italic = False
End If
Next Paragraph
NrPara = 0
Set aRng = Nothing
|
|
#18
|
|||
|
|||
|
You don't need a range object for that solution. You need a paragraph object.
30 what? centimeters, inches, yards, meters or points? Code:
Sub ScratchMacro()
'A basic Word Macro coded by Gregory K. Maxey
Dim oPar As Paragraph
For Each oPar In ActiveDocument.Paragraphs
If oPar.Range.ParagraphFormat.Alignment = wdAlignParagraphRight _
Or oPar.Range.ParagraphFormat.LeftIndent > 30 Then
oPar.Range.Font.Italic = False
End If
Next oPar
lbl_Exit:
Set oPar = Nothing
Exit Sub
End Sub
|
|
#19
|
|||
|
|||
|
Many thanks, Gmaxey! Of course you are right also for the declarations and the Option Explicit. The 30 in the code refers to points, which are my default measure.
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Find & Replace to insert thousands separators
|
jeffreybrown | Word | 3 | 10-19-2019 04:37 PM |
Find and replace condition
|
norgro | Word VBA | 2 | 07-31-2015 06:38 AM |
Find and Replace - How to insert brackets around all numbers in a doc
|
Natedogg | Word | 2 | 05-21-2015 07:16 AM |
Insert text at the end of a sentence Find/Replace
|
AlmostFriday | Word | 6 | 06-17-2012 05:21 AM |
| Find & Replace Insert Issue | mipacker | Word | 0 | 02-18-2009 08:59 AM |