![]() |
|
#1
|
||||
|
||||
![]() Your four macros are equivalent to: Code:
Sub Colorize() With ActiveDocument With .Background.Fill .ForeColor.TintAndShade = 0 .Visible = msoTrue .Solid End With Select Case .Range.Font.ColorIndex Case wdWhite Select Case .Background.Fill.ForeColor.RGB Case RGB(0, 0, 255) 'Blue .Background.Fill.ForeColor.RGB = RGB(0, 0, 0) 'Black Case RGB(0, 0, 0) 'Black .Range.Font.ColorIndex = wdAuto .Background.Fill.ForeColor.RGB = RGB(255, 255, 255) 'White End Select Case wdAuto, wdBlack Select Case .Background.Fill.ForeColor.RGB Case RGB(255, 255, 255) 'White .Background.Fill.ForeColor.RGB = RGB(255, 255, 0) 'Yellow Case RGB(255, 255, 0) 'Yellow .Range.Font.ColorIndex = wdWhite .Background.Fill.ForeColor.RGB = RGB(0, 0, 255) 'Blue End Select End Select End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#2
|
|||
|
|||
![]()
Thanks! This is the code I ended up with. There is one issue thou! Some times it will not execute if the documents start with yellow background fill. And some times it will not execute if the document starts with black background fill.
Is there a reason for that? There is no problem to start with a black background, but it don's seem consequent. Code:
Sub BytteFargekombinasjon() With ActiveDocument With .Background.Fill .ForeColor.TintAndShade = 0 .Visible = msoTrue .Solid End With Select Case .Range.Font.ColorIndex Case wdWhite 'HvitSkrift Select Case .Background.Fill.ForeColor.RGB Case RGB(0, 0, 255) 'BlåBakgrunn .Background.Fill.ForeColor.RGB = RGB(0, 0, 0) 'SvartBakgrunn Case RGB(0, 0, 0) 'Svart .Range.Font.ColorIndex = wdAuto .Background.Fill.ForeColor.RGB = RGB(255, 255, 255) 'HvitBakgrunn End Select Case wdAuto, wdBlack 'SvartSkrift Select Case .Background.Fill.ForeColor.RGB Case RGB(255, 255, 255) 'HvitBakgrunn .Background.Fill.ForeColor.RGB = RGB(255, 255, 0) 'GulBakgrunn Case RGB(255, 255, 0) .Range.Font.ColorIndex = wdWhite .Background.Fill.ForeColor.RGB = RGB(0, 0, 255) 'BlåBakgrunn End Select End Select End With End Sub Last edited by macropod; 06-30-2014 at 12:02 AM. Reason: Added code formatting |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
gsrikanth | Excel | 8 | 11-05-2022 04:10 AM |
![]() |
sparkync | Office | 3 | 08-04-2012 03:26 PM |
![]() |
nja | Word VBA | 1 | 10-24-2009 05:07 AM |
Where is the MS Office Shortcut Bar? | vwm12345 | Office | 0 | 11-14-2008 04:30 AM |
Style shortcut | billzant | Word | 0 | 01-06-2007 02:13 AM |