Applescript help | Newbie | copy & paste

I am looking for an easy solution to copy text from a web page (always in the same location) into to a specific location in Word and print.

tell application “Google Chrome”
activate
tell application “Google Chrome” Get id=“customer-name-first” {not sure how to execute this part}
tell application “System Events” to keystroke “c” using command down
end tell

tell application “Microsoft Word”
activate

tell application “Microsoft Word”
set findRange to find object of selection
tell findRange
execute find find text “xxx” replace with “CLIPBOARD” replace {not sure how to get the clipboard pasted here}
replace all
tell application “System Events” to keystroke “v” using command down

I don’t have (or use) Chrome, but I strongly suspect that it is (like Firefox) not scriptable.

I recommend to use an Automator service which can take selected text as input value

Thanks for the suggestion, I tried that and it kept failing, would open the word document and then error that word wasn’t available :frowning:

Hello.

I think something along the line below should work.


tell application "System Events" to tell Application process "Chrome" to keystroke "C" using command down

Thanks I’ll give that a try

but not sure how to successfully action this line

tell application "Google Chrome" Get id="customer-name-first"

any idea?

I just tested this Run AppleScript action, which creates a new document and pastes the selected text, works fine


on run {input, parameters}
	
	tell application "Microsoft Word"
		launch
		activate
		make new document at end of documents
		tell document 1
			set content of text object to input
		end tell
	end tell
	return input
end run

In Automator I selected
Service receives selected text in any application

Thanks but

what I am trying to achieve is to copy the text from a browser element
open word find the string of text that is xxx
select it and replace it with the clipboard contents

I don’t know the dictionary of word very well.
The variable input contains the selected text, the clipboard is not needed

Hello.

Look here for how to use javascript with Chrome and AppleScript