Hi Guys,
I'm looking to run a macro when a hyperlink is pressed in Open Office CALC. Is there a way to go about doing that?
[Solved] Running macro when a hyperlink is pressed
[Solved] Running macro when a hyperlink is pressed
Last edited by Redfantic on Tue Sep 20, 2011 4:34 pm, edited 1 time in total.
OpenOffice 3.3 on Windows 7
Re: Running macro when a hyperlink is pressed
Formula to call Basic routine Standard.Module1.Main stored in this document passing a userdefined argument from cell A1:
Code: Select all
=HYPERLINK("vnd.sun.script:Standard.Module1.Main?language=Basic&location=document&MyArgument="&A1)
Code: Select all
Sub Main(sURL)
Const cArgName = "MyArgument"
myVar = getArgumentFromURL(sURL,cArgName)
End Sub
REM returns "" if no value was found for name.
Function getArgumentFromURL(sURL$,sName$) as String
on error goto exitErr:
Dim iStart%, i%, l%, sArgs$, a()
iStart = instr(sURL, "?")
l = len(sName)
if (iStart = 0) or (l = 0) then exit function
' sArgs behind "?":
sArgs = mid(sURL, iStart +1)
a() = split(sArgs, "&")
for i = 0 to uBound(a())
' not case sensitive:
if instr(1, a(i), sName &"=", 1) = 1 then
getArgumentFromURL = mid(a(i), l +2)
exit for
endif
next
exitErr:
' return ""
End Function
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Running macro when a hyperlink is pressed
I'm Sorry, I don't quite understand the code as I'm New to VB programming.
Is it possible to explain how the code works?
Is it possible to explain how the code works?
OpenOffice 3.3 on Windows 7
Re: Running macro when a hyperlink is pressed
A forum can not teach you how to program.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Running macro when a hyperlink is pressed
Alright. Thanks for the help though
OpenOffice 3.3 on Windows 7
Re: [Solved] Running macro when a hyperlink is pressed
Anyhow, the hyperlink vnd.sun.script:Standard.Module1.Main?language=Basic&location=document
calls Basic macro Standard.Module1.Main of this document. location=application calls the macro in the global name space.
calls Basic macro Standard.Module1.Main of this document. location=application calls the macro in the global name space.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice