View Single Post
 
Old 08-19-2018, 06:46 AM
jeffreybrown jeffreybrown is offline Windows Vista Office 2007
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Thanks Graham. This works great.

It did not appear that this macro was looping thru the entire selection, so I did my best to update it to a For next statement and this seems to work great.

I didn't want the comma's to take on the applied format, so I removed the oRng.End part.

All seems to work well and I appreciate your time.

Code:
Sub FormatReferencePara()
    Dim oPara   As Paragraph
    Dim oRng    As Range
    Dim oSel    As Range
    
    Set oSel = Selection.Range
    
    For Each oPara In oSel.Paragraphs
        Set oRng = oPara.Range
        oRng.Collapse 1
        oRng.MoveEndUntil Chr(44)
'        oRng.End = oRng.End
        oRng.Style = "Strong"
        oRng.Collapse 0
        oRng.MoveEndUntil Chr(44)
'        oRng.End = oRng.End
        oRng.Style = "Subtle Emphasis"
        oSel.Select
    Next oPara
    
lbl_Exit:
    Set oRng = Nothing
    Set oSel = Nothing
    Exit Sub

End Sub
Reply With Quote