View Single Post
 
Old 12-06-2023, 05:00 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

A couple of things. First, I agree with Andrew. Secondly, you are making use of more declared variables than you need. Thirdly, and this is just a matter of style and a recommendation, I would change variable naming convention.


Range is an object. Paragraph is an object. Range is a property of document object. Paragraphs is a property of the document object. Range is also a property of the paragraph object. So you can replace all this mash:

Set aRng = ActiveDocument.Range
aRng.End = ActiveDocument.Range.End
For Each aPara in aRng.Paragraps


with

For Each aPara in ActiveDocument.Paragraphs


Code:
Sub FontSize()
Dim oPar As Paragraph
  For Each oPar In ActiveDocument.Paragraphs
    If oPar.Range.Font.Size = wdUndefined Then oPar.Range.HighlightColorIndex = wdBrightGreen
  Next oPar
End Sub

Since Range is a object, why not use oRng instead of aRng, oPar instead of aPar


strWhatever for strings, varWhatever for variants, bWhatever for boolean (e.g., bCheck instead of just Chect), lngWhatever for Longs etc.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote