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