Link to browser in Writer

It would be very helpful to have a way to highlight a word or phrase in Writer and select it to open a search in a browser to find that word or phrase.

I do considerable research when I’m writing and have to copy and paste words and phrases into my browser search. Google Docs does this, but, of course, that is all done from within the browser.

Select the text to use as hyperlink and then [Crrl+] or Menu/Insert/Hyperlink.

Ratslinger,

You were kind enough to provide me a macro to look up phrases from Writer documents. It works well with firefox, but will not reliably work with google-chrome. I learned a bit about writing macros and added a line code to the end:

    Shell(ConvertToURL("google-chrome"),1,sGooglePhrase)
    Shell(ConvertToURL("firefox"),1,sGooglePhrase)

The firefox window appears, but the google-chrome window does not. Also, I can type google-chrome into a terminal window and it works.

Is there a problem in ConvertToURL with the hyphen in google-chrome?

No, that’s not it. I created a hyphenated bash script (“part1-part2”) that just ran google-chrome $1 and it worked fine when executed from Shell.

Hello,

Have recently answered this here → Internet lookup.

The solution is to use a macro. The text is highlighted then a right click and select Google_search. Have just retested this on Mint 18.3 using LO v 6.1.0.3 and have no problems.

Sample (macros included) — InternetSearch.odt

Please refrain from comments such as Google Docs does this.... It doesn’t matter who else does what. If LO doesn’t do something then a request should be made on Bugzilla.

EDIT:

Sorry but I should have mentioned that the macro in the sample is set to use Firefox. If you use a different browser, the macro must be changed.

Edit 2018-09-29:

Not certain why you are having the problem. Have taken this same sample and it obtains whatever is highlighted each time:

Edit #2 2018-09-29:

On the original site where the code is posted, there is a second routine (similar to the first). This one uses the default browser. Also, if a word/phrase is not selected it will search on the word the cursor is on or nearest to.

Sample #2 ---- InternetSearch2.odt

Edit #3 2018-09-29:

From menu → Tools->Customize and on Context Menus tab:

Notice on left panes the Category of Macros was selected from dropdown list (near bottom). This list the macros available in your document & for the modules. If you want this to be available across ALL Writer documents, you should place the macro in My Macros before assigning this. In the right panes notice my scope was for the document. You could choose Writer. The Target is Text. Once you select the macro wanted and the target, use the arrow (middle section) to create an entry on the right. You can use the Modify button to give it a new name . You can also use the up/down arrows on the far right to move the entry in the list of items.

HTH

Thank you. I’ve tried to use the macro in the example document you supplied. I first changed the browser to “google-chrome”. With this I either got an error message from Chrome or nothing. I changed the browser back to “firefox” and still got nothing. (I can execute firefox in a terminal window, so I know it’s there.) I’ve also tried Tools>Macros>Run Macro, but no luck.

What OS & LO version are you using?

I changed the Macro Security Level to Medium. I got a lookup from firefox (locomotive) once. But not a second time.

Ubuntu 16.04. Latest update. LO 6.0.6.2

Through trial and error, I got this to work in a terminal:

firefox Google

Tried that in macro:

 sGooglePhrase = "https://www.google.com/#q=%22"+sSendPhrase+"%22"

and it works the same for me as the original statement. You may want to try.

I think I must have disabled macros somehow when I first opened your example doc. I reopened your example, and when it asked if I waned to enable or disable macros, I picked “enable.”

So now it works. My mistake. Thank you very much.

I’m trying to add Google_search to the context menu. I see in your example that you have “Google_search” in the text context menu. I have tried to do that, but I can only get it to add a separator or submenu. Also, I don’t see how to assign a macro to the menu item. I’ve looked at the documentation, but I think some of it is old or I haven’t found the right sections. Is there any advice you can give me about adding the menu item and the macro?

Will edit answer with info on context menu. Hope you looked at 2nd sample as I believe it is actually better than first.

Also, as you have been helped, please help others to know the question has been answered by clicking on the :heavy_check_mark: in upper left area of answer which satisfied the question.

Yes, thank you. I will certainly click the checkmark.

You did quite a bit of work on it. I appreciate it. Others will certainly benefit.

Unfortunately, I cannot find your Google_search entry in the Text context menu. I saw it once, but not now. Sigh. Never mind. Found it. Just need to know how to assign a macro to the menu item - and how to get a single menu item in the list, not a submenu.

Make sure Scope is correctly selected. Mine is set in the document and not writer. See answer for more info.

Okay. Found it. Thank you. I didn’t see the two items on the bottom of the list. I very much appreciate your help. It works now. Whew!