Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-15-2013, 10:04 AM
Redbarn Redbarn is offline change One highlight Color to Another Windows XP change One highlight Color to Another Office 2007
Novice
change One highlight Color to Another
 
Join Date: Mar 2013
Posts: 1
Redbarn is on a distinguished road
Angry change One highlight Color to Another

A have many documents that use several highlight colors to denote option. When the selection is made I want to remove the highlight color.

I have found a macro that nearly does what I want but it changed all highlight colours.

The macro I found is below:
Code:
Sub ChangeColor()
Options.DefaultHighlightColorIndex = wdBrightGreen
Selection.Find.ClearFormatting
Selection.Find.Highlight = True
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Highlight = True
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Font.Color = wdColorBrightGreen
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = wdColorRed
With Selection.Find
  .Text = ""
  .Replacement.Text = ""
  .Forward = True
  .Wrap = wdFindContinue
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Any suggestions of modifying it to allow for selection of a specific color and changing it to NoColor.

My apologies for a very basic understanding of VBA!

Last edited by macropod; 03-16-2013 at 01:40 PM. Reason: Added code tags & formatting
Reply With Quote
  #2  
Old 03-16-2013, 02:03 PM
macropod's Avatar
macropod macropod is offline change One highlight Color to Another Windows 7 64bit change One highlight Color to Another Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Redbarn,

Try something along the lines of:
Code:
Sub ChangeColor()
Dim StrColor
StrColor = InputBox("Please choose a colour (by number):" & vbCr & _
  vbTab & "Auto" & vbTab & vbTab & "0" & vbCr & _
  vbTab & "Black" & vbTab & vbTab & "1" & vbCr & _
  vbTab & "Blue" & vbTab & vbTab & "2" & vbCr & _
  vbTab & "BrightGreen" & vbTab & "4" & vbCr & _
  vbTab & "DarkBlue" & vbTab & vbTab & "9" & vbCr & _
  vbTab & "DarkRed" & vbTab & vbTab & "13" & vbCr & _
  vbTab & "DarkYellow" & vbTab & "14" & vbCr & _
  vbTab & "Gray25" & vbTab & vbTab & "16" & vbCr & _
  vbTab & "Gray50" & vbTab & vbTab & "15" & vbCr & _
  vbTab & "Green" & vbTab & vbTab & "11" & vbCr & _
  vbTab & "Pink" & vbTab & vbTab & "5" & vbCr & _
  vbTab & "Red" & vbTab & vbTab & "6" & vbCr & _
  vbTab & "Teal" & vbTab & vbTab & "10" & vbCr & _
  vbTab & "Turquoise" & vbTab & "3" & vbCr & _
  vbTab & "Violet" & vbTab & vbTab & "12" & vbCr & _
  vbTab & "White" & vbTab & vbTab & "8" & vbCr & _
  vbTab & "Yellow" & vbTab & vbTab & "7", "Colour Picker", 0)
With Selection.Find
  .ClearFormatting
  .Text = ""
  .Highlight = True
  .Replacement.Text = ""
  .Replacement.Font.ColorIndex = StrColor
  .Replacement.Highlight = False
  .Forward = True
  .Wrap = wdFindContinue
  .Execute Replace:=wdReplaceOne
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
color change for same shape ajkiran PowerPoint 1 11-10-2012 07:41 AM
change One highlight Color to Another Change standard highlight text color to user defined Scott Duffens Word 2 06-18-2012 03:53 PM
change One highlight Color to Another how to change page color gezz7louise Word 2 11-06-2011 07:51 AM
Change skin color of applications? Jack R Office 0 07-04-2010 04:25 AM
find - reading highlight - highlight all / highlight doesn't stick when saved bobk544 Word 3 04-15-2009 03:31 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:40 PM.


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