Consulting

Results 1 to 3 of 3

Thread: VBA to auto highlight text

  1. #1

    VBA to auto highlight text

    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!

  2. #2
    have created an input that will highlight text entered there called by keyboard shortcut.... better than nothing!

  3. #3
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Sub Doc_BeforeKeyUp(???)
    Static Trapping as boolean
    Static StartSelection as Range? Long?
    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
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •