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

Creating a macro - Writing a Script - Using the API

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

Postby hcchan » Tue May 16, 2017 4:00 pm

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
hcchan
 
Posts: 4
Joined: Mon May 15, 2017 10:37 pm

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

Postby Zizi64 » Tue May 16, 2017 4:11 pm

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; LibreOffice4.4.7 - Portable versions: LO3.3.0-LO5.3.3 and AOO4.1.3; on Win7x64Prof.
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5137
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

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

Postby hcchan » Tue May 16, 2017 4:20 pm

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
hcchan
 
Posts: 4
Joined: Mon May 15, 2017 10:37 pm

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

Postby Zizi64 » Tue May 16, 2017 6:07 pm

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   Expand viewCollapse view
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   Expand viewCollapse view
oSheet.hidePrecedents(oCell.CellAddress)

API command.
Tibor Kovacs, Hungary; LibreOffice4.4.7 - Portable versions: LO3.3.0-LO5.3.3 and AOO4.1.3; on Win7x64Prof.
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 5137
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

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

Postby hcchan » Tue May 16, 2017 7:43 pm

That works.
Thanks!
OpenOffice 4.1 on Windows
hcchan
 
Posts: 4
Joined: Mon May 15, 2017 10:37 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 7 guests