[Solved] How to stop the beep from trace precedents, macro?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
hcchan
Posts: 4
Joined: Mon May 15, 2017 10:37 pm

[Solved] How to stop the beep from trace precedents, macro?

Post by hcchan »

I am writing a macro with trace precedents, and the beeps are not wanted.
Is there a way to stop the beeps within a macro?
I don't want to ask users of the macro to change their system settings (control panel, beep, or sound volume).

More specifically, is there a way to stop this dispatch from beeping?
oDispatcher.executeDispatch(oDoc, ".uno:ShowPrecedents", "", 0, Array())

I notice that LibreOffice Calc does not give beeps for this dispatch, but OpenOffice Calc does.

Thank you for any help.
Last edited by hcchan on Tue May 16, 2017 7:43 pm, edited 1 time in total.
OpenOffice 4.1 on Windows
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: How to stop the beep from trace precedents with a macro?

Post by Zizi64 »

I notice that LibreOffice Calc does not give beeps for this dispatch, but OpenOffice Calc does.
The LibreOffice is not approproiate for you?


Can you upload your example ODF file together with the embedded macro code here?
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.
hcchan
Posts: 4
Joined: Mon May 15, 2017 10:37 pm

Re: How to stop the beep from trace precedents with a macro?

Post by hcchan »

This macro shows the beep effects.
Sub test()
Dim oController As Variant
Dim oDocument as object
Dim oDispatcher As Object
oController = ThisComponent.CurrentController
oDocument = oController.Frame
oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
oDispatcher.executeDispatch(oDocument,".uno:ShowPrecedents", "", 0, Array())
End Sub
The macro works as expected, with the trace precedent arrows drawn properly.
It is just the beeps that I want to stop.
When an empty cell is selected, this macro beeps.
When a formula cell is selected, this macro beeps when there is no more precedent level to go.
BTW, I can use LibreOffice Calc, but I will like to use the macro in OpenOffice also.
OpenOffice 4.1 on Windows
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: How to stop the beep from trace precedents with a macro?

Post by Zizi64 »

When an empty cell is selected, this macro beeps.
Try to call the API functions directly, instead of calling by the Dispatcher:

Code: Select all

Sub test()

 'Dim oController As Variant
 'Dim oDocument as Object
 Dim oSheet as Object
 Dim oCell as Object
 'Dim oDispatcher As Object

	'oController = ThisComponent.CurrentController
	'oDocument = oController.Frame
	'oDispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
	'oDispatcher.executeDispatch(oDocument,".uno:ShowPrecedents", "", 0, Array())

	oSheet = ThisComponent.getCurrentController.ActiveSheet
	oCell = ThisComponent.getCurrentSelection()
	oSheet.showPrecedents(oCell.CellAddress)	
End Sub
It is not beeping for me in my AOO 4.1.3 portable.

You can hide the Precedents by the

Code: Select all

oSheet.hidePrecedents(oCell.CellAddress)
API command.
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.
hcchan
Posts: 4
Joined: Mon May 15, 2017 10:37 pm

Re: How to stop the beep from trace precedents with a macro?

Post by hcchan »

That works.
Thanks!
OpenOffice 4.1 on Windows
Post Reply