Reputation: 450
I have trouble making hyperlink within macro.
For example just create empty spreadsheet and create another sheet within so we have 2 empty sheets.
In Sheet1 A:1 just paste =HYPERLINK("#Sheet2")
For A:3 create macro and execute it
Sub TestMacro
dim document as object
oSheet = thiscomponent.sheets.getByName("Sheet1")
oCell = oSheet.getCellRangeByName("$A$3")
xx="=HYPERLINK(""#Sheet2"")"
oCell.setString(xx)
End Sub
So sheet1 now have something on cell A1 and A3. the both should be link but just A1 works. If jou press CTRL+click on Sheet1 A1 the Sheet2 is selected. If you press CTRL+click on Sheet1 A3 nothing happens
I tested ou xubuntu 18.04LTS LibreOffice Version: 6.0.7.3 Build ID: 1:6.0.7-0ubuntu0.18.04.10
Upvotes: 2
Views: 506
Reputation: 13819
For functions and calculations, set the cell formula instead of a literal string value.
oCell.setFormula(xx)
Upvotes: 1