Link to browser in Writer

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!

I would like to know how to import this macro ( InternetSearch2.odt ) so it works for all of my Writer documents. So far, it only works when I open the macro directly into Writer. Thank you.

@msea,

The explanation is in the last paragraph of the answer. The macro needs to be copied into the Standard library under MyMacros. It can be in any module under the Standard library there. The Standard library is loaded automatically when LibreOffice is started.

Just re-tested and works for me Currently on Ubuntu 20.04 Mate with LO v6.4.5.2 and tested with Firefox as default.

I did see that last paragraph you mention and tried to figure it out. I am assuming one copies the maco file into a folder thru either the Windows or Linux folder system. I am using Windows 10 64 bit and cannot find the folder called My Macros. If my approach is correct, pls let me know where I can find that folder. If my approach is not correct, please instruct otherwise. Thanks.

@msea,

Best if you look at the documentation → here. See Getting Started with LibreOffice section and look at Chapter #13 - Getting Started with Macros.

Thanks for the lead and your time. I am sure I will figure it out. Just needed a point in the right direction. Good to hear it also works in Linux as I’m a fan of Lubuntu. I may switch permanently someday soon. Cheers.