Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-27-2015, 10:48 AM
AustinBrister AustinBrister is offline I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Windows 7 64bit I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Office 2013
Novice
I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro?
 
Join Date: May 2015
Posts: 16
AustinBrister is on a distinguished road
Default I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro?

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!
Reply With Quote
  #2  
Old 05-27-2015, 03:00 PM
gmaxey gmaxey is offline I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Windows 7 32bit I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,236
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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/...ng_macros.html for instructions to employ the VBA code provided above.


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.
Reply With Quote
  #3  
Old 05-28-2015, 12:48 PM
AustinBrister AustinBrister is offline I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Windows 7 64bit I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Office 2013
Novice
I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro?
 
Join Date: May 2015
Posts: 16
AustinBrister is on a distinguished road
Default

Awesome! Thanks!!!
Reply With Quote
  #4  
Old 05-28-2015, 12:50 PM
AustinBrister AustinBrister is offline I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Windows 7 64bit I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Office 2013
Novice
I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro?
 
Join Date: May 2015
Posts: 16
AustinBrister is on a distinguished road
Default

I'm getting an error:

Reply With Quote
  #5  
Old 05-28-2015, 01:41 PM
gmaxey gmaxey is offline I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Windows 7 32bit I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,236
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
Reply With Quote
  #6  
Old 05-28-2015, 02:23 PM
AustinBrister AustinBrister is offline I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Windows 7 64bit I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Office 2013
Novice
I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro?
 
Join Date: May 2015
Posts: 16
AustinBrister is on a distinguished road
Default

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?
Reply With Quote
  #7  
Old 05-28-2015, 02:39 PM
gmaxey gmaxey is offline I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Windows 7 32bit I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,236
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
Reply With Quote
  #8  
Old 05-28-2015, 02:40 PM
AustinBrister AustinBrister is offline I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Windows 7 64bit I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Office 2013
Novice
I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro?
 
Join Date: May 2015
Posts: 16
AustinBrister is on a distinguished road
Default

My god, man.... you're amazingly good at this and quick.
Reply With Quote
  #9  
Old 05-28-2015, 02:42 PM
gmaxey gmaxey is offline I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Windows 7 32bit I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? Office 2010 (Version 14.0)
Word MVP 2003-2009
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,236
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Well I've been doing it for awhile. Glad I could help.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? 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
I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? How to make a style with shaded background and indented text? Katarina Word 4 03-25-2014 01:12 AM
I need to convert shaded text into highlighted text on about 80 different long documents. VBA macro? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 10:51 PM.


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