In MS Word automate Find and Replace function

Discussion, questions and support.
Post Reply
Fazlul
Posts: 6
Joined: Jun 23rd, ’21, 11:39

Post by Fazlul » Jun 23rd, ’21, 11:46

Hi Everyone,

I am new in Fastkeys.
I am having difficulty automating a process by Fastkeys Key shortcut. My problem is as follows:

Problem: Whenever I copy some continuous sentences of a paragraph from a pdf (adobe, Nitro pdf) document and paste them in MS Word (2016), they get broken into smaller lines and I have to use Delete/backspace and space button to combine them in a paragraph.

What I do manually: I select the whole text, press Ctrl+H, a Find and Replace dialogue box pops up, in first box input, I type ^p, press Tab to go next input box, press Space bar once, then press Alt+A to replace all, then another small pop up window wants me to confirm searching rest of the doc by Yes and No button, I Click No button. When I click No, it is gone. Then I click Close button of the original Find and Replace pop -up. Done

What I want from Fastkeys: I will manually select the text, then Press shortcut key (eg, Ctrl+Shift+P) and Fastkeys will automate the manually done activities I mentioned above in "What I do manually".

I need it for my personal research work.
So, your kind help will be highly appreciated.

Thanks in advance
Fazlul
Fazlul
Posts: 6
Joined: Jun 23rd, ’21, 11:39

Post by Fazlul » Jun 23rd, ’21, 14:04

Finally, I have done it, Al-Hamdu-Lillah

I recorded a macro in the command line like this:

Send, ^h^p{Tab} !a{Right}{Enter}{Escape}^j

With bonus justify the paragraph.

Thanks to Fastkeys
User avatar
Tom
Posts: 791
Joined: Nov 24th, ’15, 23:39

Post by Tom » Jun 24th, ’21, 11:46

Another way would be to use this script which replaces all hard returns in the selected text with spaces. Set it as a Shortcut (Type: Command).

Code: Select all

Send, ^c
Sleep 100
StringReplace, clipboard, clipboard, `r`n`r`n, |, All
StringReplace, clipboard, clipboard, `r`n, %A_Space%, All
StringReplace, clipboard, clipboard, |,`r`n`r`n, All
Send, ^v
Fazlul
Posts: 6
Joined: Jun 23rd, ’21, 11:39

Post by Fazlul » Jul 2nd, ’21, 18:27

Tom wrote: Jun 24th, ’21, 11:46 Another way would be to use this script which replaces all hard returns in the selected text with spaces. Set it as a Shortcut (Type: Command).

Code: Select all

Send, ^c
Sleep 100
StringReplace, clipboard, clipboard, `r`n`r`n, |, All
StringReplace, clipboard, clipboard, `r`n, %A_Space%, All
StringReplace, clipboard, clipboard, |,`r`n`r`n, All
Send, ^v
Thank you very much.
Post Reply