Thursday, January 13, 2022

Weird Word Question

 I have a Word macro that takes a selected block of text, puts every word in first letter upper case, then applies a style.  Right now, I have to paste the text, select it, then run the macro.  I wish that I had a way to paste the text and then select and do the rest of the macro.  I cannot figure out how to paste and select only the pasted text.  It is not a consistent number of words (e.g., "Henderson county register" "Indianapolis Times").  

I tried F8 before the paste, but that does not create a selection on the pasted text.

I tried pug an unique character first \ then paste text, then F8, then search for the \.  

Any suggestions?

2 comments:

  1. I think you'll have to have the macro do the pasting. There doesn't seem to be an easy way to select text that was just pasted in an ordinary manner.

    Perhaps define a variable MyRange as Range, set it to the range of the current selection or insertion point, then MyRange.paste which will expand MyRange to include the pasted contents, followed by MyRange.select to create a selection that the code of your current macro can format.

    ReplyDelete
  2. Thanks to all. I retried inserting a \ before paste, then searched for \, deleted it, F8 then End of line, Capitalize, and apply style. That works.

    ReplyDelete