PDA

View Full Version : [SOLVED:] Select and colour to end of document



stevetalaga
02-24-2014, 12:49 AM
I would like to write some code to select from the current cursor position to the end of the document and then colour that selected text to a specific RGB colour. It sounds easy but as a real novice I am still scratching my head on this.

Any hints would be much appreciated.

Thanks

macropod
02-24-2014, 12:59 AM
Generally-speaking, applying direct formatting isn't a good idea. Better to manage this kind of thing via Paragraph and/or Character Styles. That said, you could use:

Sub Demo()
With Selection
.EndKey wdStory, wdExtend
.Font.Color = RGB(100, 127, 255)
.Collapse wdCollapseStart
End With
End Sub

stevetalaga
02-24-2014, 09:25 PM
Great thanks Paul - Will try that when I get home :beerchug:

stevetalaga
02-24-2014, 11:06 PM
Works a treat - Exactly what I wanted to do - Thanks very much!