PDA

View Full Version : [SOLVED:] VBA to auto highlight text



ID015
05-11-2016, 07:04 AM
I need some ideas again for some code to auto highlight text within some delimitations.
As someone types in the document, text within a curly bracket should be highlighted until it's closed {highlighted text}

Any suggestions? I know I could do with a replace all, though I would like to have the function when typing.
Thanks!

ID015
05-20-2016, 08:40 AM
have created an input that will highlight text entered there called by keyboard shortcut.... better than nothing!

SamT
05-20-2016, 05:11 PM
Sub Doc_BeforeKeyUp(???)
Static Trapping as boolean
Static StartSelection as Range? Long? :dunno
Static EndSelection As Range???

If not Trapping then
If KeyAscii = { then
StartSelection = Range
Trapping = True
Exit Sub
Else
If AsciiKey <> } Then
End Selection = Range???
Range(StartSelection, EndSelection) Highlight = True
Else
Range(StartSelection, EndSelection) Highlight = False
set StartSelection and EndSelection = Nothing
Let Trapping = False
End If
End if