![]() |
|
|||||||
|
|
|
Thread Tools | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Title pretty much says it all. I'm looking for a VBA to convert all shaded text into highlighted text. Right now I have documents that have been highlighted by choosing "Shading" within the Paragraph section of the ribbon. These need to be highlights instead. VBA to convert these?
Thanks in advance! |
|
#2
|
|||
|
|||
|
Something like:
Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oPar As Paragraph
For Each oPar In ActiveDocument.Paragraphs
If oPar.Range.Shading.BackgroundPatternColor <> wdColorAutomatic Then
oPar.Range.Shading.BackgroundPatternColor = wdColorAutomatic
oPar.Range.HighlightColorIndex = wdYellow
End If
Next oPar
lbl_Exit:
Exit Sub
End Sub
See: http://gregmaxey.com/word_tip_pages/...der_addin.html The code above could easily be adapted to be run as a user defined batch process. |
|
#3
|
|||
|
|||
|
Awesome! Thanks!!!
|
|
#4
|
|||
|
|||
|
I'm getting an error:
|
|
#5
|
|||
|
|||
|
Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oPar As Paragraph
For Each oPar In ActiveDocument.Paragraphs
If Not oPar.Range.Information(wdWithInTable) Then
If oPar.Range.Shading.BackgroundPatternColor <> wdColorAutomatic Then
oPar.Range.Shading.BackgroundPatternColor = wdColorAutomatic
oPar.Range.HighlightColorIndex = wdYellow
End If
End If
Next oPar
lbl_Exit:
Exit Sub
End Sub
|
|
#6
|
|||
|
|||
|
Ok, thank you so much, we're almost htere!!!
This code now works as to ENTIRE paragraphs that are shaded, but not when only a portion of words within a paragraph are shaded. Is there a workaround for that? |
|
#7
|
|||
|
|||
|
In that case, I think you are going to have to evaluate each character:
Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oChrRange As Range
For Each oChrRange In ActiveDocument.Characters
If Not oChrRange.Font.Shading.BackgroundPatternColor = wdColorAutomatic Then
oChrRange.Font.Shading.BackgroundPatternColor = wdColorAutomatic
oChrRange.HighlightColorIndex = wdBrightGreen
End If
Next oChrRange
lbl_Exit:
Exit Sub
End Sub
|
|
#8
|
|||
|
|||
|
My god, man.... you're amazingly good at this and quick.
|
|
#9
|
|||
|
|||
|
Well I've been doing it for awhile. Glad I could help.
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Macro to convert text to endnote?
|
Orifacious | Word VBA | 27 | 03-29-2022 02:58 PM |
| Hide all text in shaded table cells | ugcheleuce | Word VBA | 3 | 03-04-2015 10:28 PM |
How to make a style with shaded background and indented text?
|
Katarina | Word | 4 | 03-25-2014 01:12 AM |
Formatting- Apply changes to highlighted text results in same change to other text
|
sential | Word | 6 | 01-10-2014 03:22 PM |
| Macro to mark non-coloured/non-highlighted text as hidden | PeterB | Word | 0 | 10-28-2009 07:54 AM |