Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-24-2024, 01:48 AM
Shelley Lou Shelley Lou is offline VBA Format text in brackets to Italics but only after cross references Windows 10 VBA Format text in brackets to Italics but only after cross references Office 2016
Expert
VBA Format text in brackets to Italics but only after cross references
 
Join Date: Dec 2020
Posts: 259
Shelley Lou is on a distinguished road
Default VBA Format text in brackets to Italics but only after cross references

I have some code that will format text within brackets to italics. I would like to modify the code to look for text in brackets only if they appear after a cross reference field or a cross reference manual number after clause, paragraph, part or schedule and format with italics. What do I need to add to the code to achieve this? Any advice would be very much appreciated.

Before Image.JPG

After Image.JPG

Cross Ref in Brackets Test.docx

Code:
Sub DPU_BracketText_Italics()
Dim oRng As Range
Set oRng = ActiveDocument.Content
With oRng.Find
.ClearFormatting
.text = "\(*\)"
.Font.Bold = False
.Forward = True
.Wrap = wdFindStop
.MatchWildcards = True
.Format = True
Do While .Execute
With oRng
.MoveEnd Unit:=wdCharacter, count:=-1
.MoveStart Unit:=wdCharacter, count:=1
.Font.Italic = True
.Font.Bold = False
.Collapse wdCollapseEnd
End With
Loop
End With
End Sub

Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Format text in brackets to Italics but only after cross references Cross-references between text boxes - no link janiceward Word 3 05-06-2016 02:51 PM
VBA Format text in brackets to Italics but only after cross references Formatting text after cross references spunkygirl1983 Word 1 03-18-2016 03:42 PM
Convert manual cross references in footnotes to other footnotes to automatic cross references ghumdinger Word VBA 7 11-20-2014 11:47 PM
VBA Format text in brackets to Italics but only after cross references Globally changing formatting of in-text cross references estube Word 1 07-08-2014 03:21 AM
VBA Format text in brackets to Italics but only after cross references Changing text in cross-references Richard B Word 3 09-11-2013 07:18 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:31 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