Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-15-2017, 04:05 AM
bnyamin bnyamin is offline Change Color (Being provided between the two codes) Windows 7 64bit Change Color (Being provided between the two codes) Office 2010 64bit
Advanced Beginner
Change Color (Being provided between the two codes)
 
Join Date: Oct 2014
Posts: 36
bnyamin is on a distinguished road
Default Change Color (Being provided between the two codes)

Hello


I need to change the color between the two codes

for exampel :AAAA & BBBB its code in body text
Attached Files
File Type: doc befor run vba 1.doc (28.5 KB, 8 views)
File Type: doc after run vba 2.doc (29.0 KB, 10 views)
Reply With Quote
  #2  
Old 05-15-2017, 06:23 AM
gmayor's Avatar
gmayor gmayor is offline Change Color (Being provided between the two codes) Windows 10 Change Color (Being provided between the two codes) Office 2016
Expert
 
Join Date: Aug 2014
Posts: 3,862
gmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to beholdgmayor is a splendid one to behold
Default

The following macro should do the trick

Code:
Sub Macro1()
Const CodeA As String = "AAAA"
Const CodeB As String = "BBBB"
Dim oRng As Range

    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:=CodeA & "*" & CodeB, MatchWildcards:=True)
            oRng.Font.ColorIndex = wdRed
            oRng.Collapse 0
        Loop
    End With
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:=CodeA)
            oRng.Font.ColorIndex = wdAuto
            oRng.Collapse 0
        Loop
    End With
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:=CodeB)
            oRng.Font.ColorIndex = wdAuto
            oRng.Collapse 0
        Loop
    End With
lbl_Exit:
    Set oRng = 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
  #3  
Old 05-15-2017, 08:18 AM
bnyamin bnyamin is offline Change Color (Being provided between the two codes) Windows 7 64bit Change Color (Being provided between the two codes) Office 2010 64bit
Advanced Beginner
Change Color (Being provided between the two codes)
 
Join Date: Oct 2014
Posts: 36
bnyamin is on a distinguished road
Default

Please accept my best thanks
Reply With Quote
  #4  
Old 05-15-2017, 10:27 PM
bnyamin bnyamin is offline Change Color (Being provided between the two codes) Windows 7 64bit Change Color (Being provided between the two codes) Office 2010 64bit
Advanced Beginner
Change Color (Being provided between the two codes)
 
Join Date: Oct 2014
Posts: 36
bnyamin is on a distinguished road
Default

I need to Creating headlines between the two codes
cut (codes and between codes)
In some paragraphs there are two or more codes for headings
for exampel : DDDD & EEEE its code in body text
Attached Files
File Type: docx befor run vb3.docx (14.4 KB, 6 views)
File Type: docx after run vb4.docx (14.5 KB, 7 views)
Reply With Quote
  #5  
Old 05-16-2017, 10:55 PM
bnyamin bnyamin is offline Change Color (Being provided between the two codes) Windows 7 64bit Change Color (Being provided between the two codes) Office 2010 64bit
Advanced Beginner
Change Color (Being provided between the two codes)
 
Join Date: Oct 2014
Posts: 36
bnyamin is on a distinguished road
Default

i need help!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Color (Being provided between the two codes) Spellchecker Macro Provided by MVP Not Checking for Grammar PSSMargaret Word VBA 2 06-09-2016 04:02 AM
Change Color (Being provided between the two codes) RGB color codes? regwitt Excel Programming 2 01-06-2015 04:51 PM
Change Color (Being provided between the two codes) Color codes as background Anderso Excel 1 12-19-2014 11:53 PM
Converting color codes in VBA Ulodesk Word VBA 7 11-24-2014 04:15 AM
Change Color (Being provided between the two codes) Codes for Word Textbox Font Color? tinfanide Word VBA 7 10-23-2012 03:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:24 PM.


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