Consulting

Results 1 to 2 of 2

Thread: Highlight certain words grabbed from textbox before paste?

  1. #1
    VBAX Regular
    Joined
    Feb 2017
    Posts
    12
    Location

    Highlight certain words grabbed from textbox before paste?

    I have a userform in which is a text box that contains text consisting of, say, 9 or 10 sentences of text. The user makes a few selections on the user form, and then the text from the text box is copied to the clipboard, and the user form is unloaded and hid.

    What I need: For the text that now lives in the clipboard, I need highlighted yellow certain words BEFORE the user presses PASTE and dumps the text into the Word Document.

    For an easy example, if the Userform's Textbox's text was "The Quick Brown Fox Jumped Over The Lazy Dog", and the user clicked Userform command button "Copy to clipboard" (which button also hides/unloads the user form), then when User selects insertion point in document and presses PASTE, the word "Brown" (and only the word Brown) would be highlighted yellow when pasted.

    In effect, I need to format the text when it resides in the clipboard and then paste it as formatted text. I cannot use a modeless user form (in MAC environment where modeless user forms are not supported). Any ideas?

  2. #2
    VBAX Regular
    Joined
    Feb 2017
    Posts
    12
    Location
    For more context: As the user makes certain selections on the Userform1, I build a string in hidden Textbox ("Hidden_Textbox") delimited by commas (","), of all of the To-Be-Highlighted words that live in the Textbook containing the 9-10 sentences of text (the "Target_Textbox"). When the user presses "Copy to Clipboard," I create an array with code Array_ofWords = split(.Hidden_Textbox.text, ","), closed the user form and pass the Array_ofWords to a new modeless Userform that instructs the user to move the cursor to the desired insertion point, and then click "Execute Paste" command button on modeless user form to insert Target_Textbox.text into Word document, then define that newly pasted text as "MyRange" and then run a find/replace and highlight yellow loop using the Array_ofWords(x) as search and replace strings.

    But on my Mac, in Office for Mac 2011, I can't call the modeless Userform and thus can't wait for the user to select insert point, paste text, select pasted paragraph, and run find/replace loop using my array. Thus, as augmentation to my original question, I am trying to conceive of a work-around for the Mac macro deployment. If I can format with yellow highlight the text that is "in memory" (i.e. on the clipboard or on the string stored in the clipboard) and then paste that as formatted text, I could just copy to clipboard and send Mac user msgbox that says "put your cursor where you want the text and press PASTE."

Posting Permissions

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