[Solved] Get entire Row when clicking a hyperlink

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
xxhajime08xx
Posts: 2
Joined: Wed Jun 28, 2017 4:18 am

[Solved] Get entire Row when clicking a hyperlink

Post by xxhajime08xx »

Hi,

Just started learning about openoffice so I might be missing something. I've already searched the forum and google for 2 days (maybe I'm not getting the keywords / terms right?)
I have a report generated by a macro, now one of the fields namely Col A contains a hyperlink. This hyperlink also calls a macro.

Code: Select all

=HYPERLINK("vnd.sun.star.script:Standard.Link.Show?language=Basic&location=document";ROW()-1)
Now the question is, "Is it possible to get the value of the entire row if I click the hyperlink?"
ie :
If I click on the hyperlink in "A1" will display a msgbox containing the value of "B1","C1",.....
If I click on the hyperlink in "A2" will display a msgbox containing the value of "B2","C2",.....
and so on

Thanks
Last edited by RoryOF on Wed Jun 28, 2017 2:14 pm, edited 2 times in total.
Reason: Added green tick [RoryOF, Moderator]
Openoffice 3.3 on Win7
hubert lambert
Posts: 145
Joined: Mon Jun 13, 2016 10:50 am

Re: Get entire Row when clicking a hyperlink

Post by hubert lambert »

Hello,

It should work using this formula:

Code: Select all

=HYPERLINK("vnd.sun.star.script:Standard.Link.Show?language=Basic&location=document&row=" & ROW()-1; ROW()-1)
and something like this as your "Show" macro:

Code: Select all

sub Show(arg1, arg2, arg3)
    doc = thiscomponent
    sheet = doc.CurrentController.ActiveSheet
    row = cdbl(split(arg1, "row=")(1))
    cells = sheet.Rows(row).queryContentCells(23).Cells
    values = ""
    for each cell in cells
        address = split(cell.AbsoluteName, "$")
        if address(2) <> "A" then
            values = values + address(2) + address(3) + ": " + cell.String
            values = values + chr(10)
        end if
    next cell
    msgbox values
end sub
AOOo 4.1.2 on Win7 | LibreOffice on various Linux systems
xxhajime08xx
Posts: 2
Joined: Wed Jun 28, 2017 4:18 am

Re: [Solved]Get entire Row when clicking a hyperlink

Post by xxhajime08xx »

Hi hubert lambert

Many thanks for the help, works like a charm.
Though I still need to check on how this will run as there are some which I'm not familiar with.
Openoffice 3.3 on Win7
Post Reply