Ask Your Question
0

How to set a macro to an sheet-event by a macro

asked 2015-09-13 20:18:56 +0200

Tuennes gravatar image

updated 2016-03-19 17:14:53 +0200

Alex Kemp gravatar image

Hi,

my scenario is the following: I'm copying a sheet internally of a Libre Calc (4.4.5.2) document by a macro (Basic). In the (source-) sheet I've linked a script to a sheet-event (OnChange). By copying this (source-) sheet the new sheet has no macro defined for the sheet-event. May there's a way to solve this problem, but i don't think so because if i do the copy manually the macro is also missing in the new sheet.

I thought that i could add the macro to the sheet-event via a script/macro, but i don't find the right commands to do so. May someone knows a howto?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2015-10-01 10:12:37 +0200

pierre-yves samyn gravatar image

Hi

For a sheet named Sheet2, to set OnDoubleClick a macro test stored in Module1 of the Standard library of the document:

sub Macro
dim Prop(1) as new com.sun.star.beans.PropertyValue

Prop(0).name = "EventType"
Prop(0).value = "Script"
Prop(1).name = "Script"
Prop(1).value = "vnd.sun.star.script:Standard.Module1.test?language=Basic&location=document" 

thiscomponent.sheets.getByName("Sheet2").Events.replaceByName("OnDoubleClick", Prop())

end sub

Event names available: "OnFocus", "OnUnfocus", "OnSelect", "OnDoubleClick", "OnRightClick", "OnChange","OnCalculate"

Regards

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-09-13 20:18:56 +0200

Seen: 659 times

Last updated: Oct 01 '15