[Solved] Macro to convert a HTTP valid web address from

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
alf50
Posts: 129
Joined: Sun Jun 13, 2010 2:55 pm

[Solved] Macro to convert a HTTP valid web address from

Post by alf50 »

Is there a Macro to convert an HTTP valid web address in an OpenOffice Calc Cell from Plain Text to a Clickable link.

I have discovered that if I simply add a space to the end of the http web link, the cell changes color and becomes clickable.

Can I do that with a Macro? I tried just adding a line saying:

oCell.string = WebLinkString & " ", but that does not seem to work.

Any suggestions?
Last edited by alf50 on Wed Dec 21, 2016 1:31 am, edited 1 time in total.
OpenOffice 4.1.14 on Mac Catalina(10.15.7), RasPi4B (TwisterOS-8/2023update) & MS Wnds10
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Macro to convert a HTTP valid web address from Plain Tex

Post by RusselB »

I've had some, though not complete, success using the HYPERLINK function.
I don't know why, but it seems to work when the optional Display Text (2nd parameter) is included, but not when it is omitted.

I know you asked for a macro, but thought this might be a decent or temporary work around.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
User avatar
Zizi64
Volunteer
Posts: 11363
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Macro to convert a HTTP valid web address from Plain Tex

Post by Zizi64 »

oCell.string = WebLinkString & " "
All of the cells contain more than one type of the content (in same time):
oCell.String
oCell.Value
oCell.Formula
oCell.FormulaLocal

Your command will set the string only. Try to set the Formula as RusselB suggested:

Code: Select all

Sub SetLink

oDoc = Thiscomponent
oSheet = oDoc.Sheets.GetbyIndex(0)
oCell = oSheet.GetCellbyPosition(0,0)

sHlink = "http://portableapps.com/apps/office/libreoffice_portable"
sHlinkText = "LibreOffice Portable"

' The chr(34) is a " character.
oCell.Formula = "=HYPERLINK(" & chr(34) & sHlink & chr(34) & ";" & chr(34) & sHlinkText & chr(34) & ")"

End Sub
You can formatting the cell "as hyperlink like text" by a custom defined cellstyle.
Last edited by Zizi64 on Fri Oct 18, 2019 12:13 pm, edited 1 time in total.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
MrProgrammer
Moderator
Posts: 4908
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Macro to convert a HTTP valid web address from Plain Tex

Post by MrProgrammer »

alf50 wrote:Is there a Macro to convert an HTTP valid web address in an OpenOffice Calc Cell from Plain Text to a Clickable link.
There is no need for an evil macro. [Tutorial] Text to Columns, Q35/A35.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
Post Reply