[Solved] Function for Search Bar (Ctrl+F)

Creating a macro - Writing a Script - Using the API

[Solved] Function for Search Bar (Ctrl+F)

Postby linuxyz » Sat Mar 03, 2018 10:56 am

Hi!
I've found the function to display the search dialog (triggered by Ctrl+H), it's
Code: Select all   Expand viewCollapse view
.uno:SearchDialog
like in :

Code: Select all   Expand viewCollapse view
dispatcher.executeDispatch(document, ".uno:SearchDialog", "", 0, Array())


But I haven't found the function to display the search bar, at the bottom (triggered by Ctrl+F), Does it exist?

Thanks a lot in advance!
Last edited by linuxyz on Sun Mar 04, 2018 11:47 am, edited 1 time in total.
openoffice 4.1.5-1 on Linux Arch
linuxyz
 
Posts: 7
Joined: Sat Mar 03, 2018 10:53 am

Re: Function for Search Bar (Ctrl+F)

Postby Zizi64 » Sat Mar 03, 2018 11:34 am

But I haven't found the function to display the search bar, at the bottom (triggered by Ctrl+F), Does it exist?

Thanks a lot in advance!
openoffice 4.1.5-1 on Linux Arch



Are you using the LibreOffice?
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.5; AOO4.1.6
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.
User avatar
Zizi64
Volunteer
 
Posts: 8328
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Function for Search Bar (Ctrl+F)

Postby Villeroy » Sat Mar 03, 2018 12:57 pm

Run this against some spreadsheet document. It generates a new spreadsheet with all availlable spreadsheet dispatches. Can be used with any other type of frame as well.
Code: Select all   Expand viewCollapse view
Sub fetchDispatchInformation()
REM dump current frame's "ConfigurableDispatchInformation" into a new spreadsheet as hyperlinks
REM if the current frame happens to be a spreadsheet frame, you can test the hyperlinks
  Dim oCurrentController As Variant
  Dim oFrame As Variant
  Dim oConfigurableDispatchInformation As Variant
  Dim oConfigurableDispatchInformation2 As Variant
  Dim oConfigurableDispatchInformation3 As Variant

  oCurrentController = ThisComponent.getCurrentController()
  oFrame = oCurrentController.getFrame()
   oDoc = StarDesktop.loadComponentFromURL("private:factory/scalc","_blank",0,Array())
   sh = oDoc.Sheets.getByIndex(0)
   c = 0

on error goto exitErr
do
  oConfigurableDispatchInformation = oFrame.getConfigurableDispatchInformation(c)
   for each p in oConfigurableDispatchInformation
      sh.getCellByPosition(c,r).setFormula("=HYPERLINK("""& p.Command &""")")
      r = r +1
   next p
  c = c +1
  r = 0
loop
exitErr:
End Sub

Made with a little help from my friend: [Tutorial] Introduction into object inspection with MRI
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27207
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Function for Search Bar (Ctrl+F)

Postby Villeroy » Sat Mar 03, 2018 1:46 pm

It is vnd.sun.star.findbar:FocusToFindbar
I found it in <profile>/config/soffice.cfg/modules/scalc/menubar/menubar.xml
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27207
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Function for Search Bar (Ctrl+F)

Postby linuxyz » Sat Mar 03, 2018 6:50 pm

Thanks a lot! I'm almost there though... How do you call it in the script?
I've tried :
Code: Select all   Expand viewCollapse view
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:FocusToFindbar", "", 0, Array())


But that's not the right thing evidently... I'm still very new to macro script, sorry.
openoffice 4.1.5-1 on Linux Arch
linuxyz
 
Posts: 7
Joined: Sat Mar 03, 2018 10:53 am

Re: Function for Search Bar (Ctrl+F)

Postby Villeroy » Sat Mar 03, 2018 8:30 pm

The url is "vnd.sun.star.findbar:FocusToFindbar".
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 27207
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Function for Search Bar (Ctrl+F)

Postby linuxyz » Sat Mar 03, 2018 10:27 pm

Sorry, I didn't changed that.
I've tried:
Code: Select all   Expand viewCollapse view
dim dispatcher as object
dim document as object
document = ThisComponent.CurrentController.Frame

dispatcher = createUnoService("vnd.sun.star.findbar", "", 0, Array())
dispatcher.executeDispatch(document, ".uno:FocusToFindbar", "", 0, Array())


But I get for the last line:
Code: Select all   Expand viewCollapse view
"object variable not set

how do I call this function?
openoffice 4.1.5-1 on Linux Arch
linuxyz
 
Posts: 7
Joined: Sat Mar 03, 2018 10:53 am

Re: Function for Search Bar (Ctrl+F)

Postby Zizi64 » Sun Mar 04, 2018 9:34 am

Please upload the full code of the subroutine (or a sample ODF file with the embedded macro).


Are you using the "Option explicit" at the begin of the Module?
If the answer is Yes, then you need declare the variable Array() too.


How to get the dispacher:
Code: Select all   Expand viewCollapse view
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
Tibor Kovacs, Hungary; LO6.1.6 on Win7-10 x64Prof.
PortableApps, winPenPack: LO3.3.0-6.2.5; AOO4.1.6
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.
User avatar
Zizi64
Volunteer
 
Posts: 8328
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Function for Search Bar (Ctrl+F)

Postby linuxyz » Sun Mar 04, 2018 11:43 am

Phew! Eventually I've got it right!
Thanks @Zizi64 and @Villeroy for the help.

Here's the code working:
Code: Select all   Expand viewCollapse view
Sub test_findbar
dim document as object
dim dispatcher as object

dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(document, "vnd.sun.star.findbar:FocusToFindbar", "", 0, Array())
End Sub
openoffice 4.1.5-1 on Linux Arch
linuxyz
 
Posts: 7
Joined: Sat Mar 03, 2018 10:53 am

Re: [SOLVED] Function for Search Bar (Ctrl+F)

Postby RoryOF » Sun Mar 04, 2018 12:27 pm

Apache OpenOffice 4.1.7 on Xubuntu 18.04.3 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 29560
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [SOLVED] Function for Search Bar (Ctrl+F)

Postby linuxyz » Sun Mar 04, 2018 12:53 pm

Nobody answered there (I've tried the mailing list too, without success). I could have deleted the post there but I thought it better not deleting it for future users...
openoffice 4.1.5-1 on Linux Arch
linuxyz
 
Posts: 7
Joined: Sat Mar 03, 2018 10:53 am

Re: [Solved] Function for Search Bar (Ctrl+F)

Postby Hagar Delest » Sun Mar 04, 2018 6:00 pm

Of course this discussion should be kept since you got your help here. This is indeed expected to be a knowledge database.
AOO 4.1.6 on Xubuntu 19.04 and 4.1.5 on Windows 7 (with winPenPack port).
User avatar
Hagar Delest
Moderator
 
Posts: 28558
Joined: Sun Oct 07, 2007 9:07 pm
Location: France


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 3 guests