Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 08-18-2018, 08:53 PM
gmayor's Avatar
gmayor gmayor is offline VBA: Set two styles in one sentence Windows 10 VBA: Set two styles in one sentence Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,143
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

Assuming each reference reflects a paragraph then put the cursor in the paragraph and the following will apply built in character styles top the relative parts of the paragraph.

Code:
Sub FormatReferencePara()
Dim oRng As Range
Dim oStart As Range
    Set oStart = Selection.Range
    Set oRng = Selection.Paragraphs(1).Range
    oRng.Collapse 1
    oRng.MoveEndUntil Chr(44)
    oRng.End = oRng.End + 1
    oRng.Style = "Strong"
    oRng.Collapse 0
    oRng.MoveEndUntil Chr(44)
    oRng.End = oRng.End + 1
    oRng.Style = "Subtle Emphasis"
    oStart.Select
lbl_Exit:
    Set oRng = Nothing
    Set oStart = Nothing
    Exit Sub
End Sub
__________________
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
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Does a new set of styles in a template overwrite or remove the existing set of styles in a document? dianahbr Word 6 03-27-2018 11:12 PM
Two much blank space between names of styles in the Styles Pane PereCasanellas Word 0 10-06-2017 03:47 AM
Question about spacing between multi-level bullet styles (and other styles) SDwriter Word 0 09-26-2017 09:39 AM
VBA: Set two styles in one sentence Delete does not bring second sentence closer to first sentence Andoheb Word 29 07-03-2014 01:48 PM
VBA: Set two styles in one sentence Quick Styles Set saved but it doesnt appear at the styles list! Pedro77 Word 3 10-15-2011 05:17 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft