K
kaprivi
I have a macro which toggles the "White Text on Blue Background"
on/off. To make sure I can read the text, I ensure that the font colour
for all text in the document is set to "automatic", however the method
I use to do this moves the insertion point to the beginning of the
document. I would like to re-position the insertion point at its
original location
I imagine that I should programmatically extract the initial location
of the insertion point, as I do in the example below, and then feed it
back into the programme when the font colour has been corrected.
I have placed some code below which I'd hoped might do the trick, but
it doesn't work. Does anyone have any suggestions?
Thanks in advance...
Sub Blue()
Dim lCol As Long
Dim lLine As Long
'extract original location of insertion point
lLine = Selection.Information(wdFirstCharacterLineNumber) - 1
lCol = Selection.Information(wdFirstCharacterColumnNumber) - 1
With Options
If .BlueScreen = False Then
Selection.WholeStory
Selection.Font.Color = wdColorAutomatic
Selection.MoveLeft Unit:=wdCharacter, Count:=1
' the commented code below gives a "bad parameter" error
' Selection.MoveDown Unit:=wdCharacter, Count:=lLine
' Selection.MoveRight Unit:=wdCharacter, Count:=lCol
.BlueScreen = True
Else
.BlueScreen = False
End If
End With
End Sub
on/off. To make sure I can read the text, I ensure that the font colour
for all text in the document is set to "automatic", however the method
I use to do this moves the insertion point to the beginning of the
document. I would like to re-position the insertion point at its
original location
I imagine that I should programmatically extract the initial location
of the insertion point, as I do in the example below, and then feed it
back into the programme when the font colour has been corrected.
I have placed some code below which I'd hoped might do the trick, but
it doesn't work. Does anyone have any suggestions?
Thanks in advance...
Sub Blue()
Dim lCol As Long
Dim lLine As Long
'extract original location of insertion point
lLine = Selection.Information(wdFirstCharacterLineNumber) - 1
lCol = Selection.Information(wdFirstCharacterColumnNumber) - 1
With Options
If .BlueScreen = False Then
Selection.WholeStory
Selection.Font.Color = wdColorAutomatic
Selection.MoveLeft Unit:=wdCharacter, Count:=1
' the commented code below gives a "bad parameter" error
' Selection.MoveDown Unit:=wdCharacter, Count:=lLine
' Selection.MoveRight Unit:=wdCharacter, Count:=lCol
.BlueScreen = True
Else
.BlueScreen = False
End If
End With
End Sub