View Single Post
 
Old 06-29-2014, 11:56 PM
orjanmen orjanmen is offline Windows 8 Office 2010 64bit
Novice
 
Join Date: Jun 2014
Posts: 7
orjanmen is on a distinguished road
Default

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
Reply With Quote