[Solved] Count property ignored for .uno:GoUp

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
wanglong
Posts: 51
Joined: Fri Sep 09, 2022 10:57 am
Location: Beijing,China

[Solved] Count property ignored for .uno:GoUp

Post by wanglong »

Code: Select all

PropertyValue[] property2 = new PropertyValue[]{new PropertyValue(),new PropertyValue()};
        property2[0].Name = "Count";
        property2[0].Value = 10;
        property2[1].Name = "Select";
        property2[1].Value = true;
xDispatchHelper.executeDispatch(xDispatchProvider, ".uno:GoUp", "", 0, property2);
For example, when I set Count to 10,but it just go up one line.
Last edited by MrProgrammer on Wed Feb 28, 2024 6:44 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
Libre Office 7.6 on Windows 11.
User avatar
Lupp
Volunteer
Posts: 3553
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: .uno:GoUp "Count" property is not work for me

Post by Lupp »

General:
1. Never post something in the "Macros ..." sub-forum without telling the language you are using and the module of "our" software (in this case Calc) the macro is made for.
2. If you post code, give a sufficiently complete part of it.
3. Best attach an example file containing the code you are asking about.
4. Be aware of the fact that .uno: commands use their own naming and syntax.
5. If you want to use .uno: commands in a written/edited macro, start your work based on a recorded example. It often can tell you much about the usage.
Specific:
The number of steps in .uno:GoUp is not named "Count" but "By".
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
wanglong
Posts: 51
Joined: Fri Sep 09, 2022 10:57 am
Location: Beijing,China

Re: .uno:GoUp "Count" property is not work for me

Post by wanglong »

I had try to use "By",it has no effect.
Libre Office 7.6 on Windows 11.
FJCC
Moderator
Posts: 9283
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: .uno:GoUp "Count" property is not work for me

Post by FJCC »

This works in OpenOffice Basic

Code: Select all

sub GoupTest
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "By"
args1(0).Value = 10
args1(1).Name = "Sel"
args1(1).Value = false

dispatcher.executeDispatch(document, ".uno:GoUp", "", 0, args1())
End Sub
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Zizi64
Volunteer
Posts: 11364
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: .uno:GoUp "Count" property is not work for me

Post by Zizi64 »

5. If you want to use .uno: commands in a written/edited macro, start your work based on a recorded example. It often can tell you much about the usage.
My addition:
Record (do not write) the recordable macros. Then you can modify them - if it is needed.
But it is better to WRITE the macros based on the API functions. It is a more effective method to control the application and the documents even if the document is in Hidden state.
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.
wanglong
Posts: 51
Joined: Fri Sep 09, 2022 10:57 am
Location: Beijing,China

Re: .uno:GoUp "Count" property is not work for me

Post by wanglong »

First of all, I would like to apologize for not being clear enough about the problem and the scenario.
  • First, I'm currently using JAVA to execute .uno: commands via executeDispatch.
  • Second, what you said about the LO/OO BASIC script is also correct when it runs in my environment.
  • Finally, I would like to reiterate the problem I am currently experiencing. I'm having trouble executing the .uno:GoUp command in JAVA. When I control the execution behavior of the command through the "Count/By" property, it does not have the expected effect, and only one line of text is always selected upwards after the command is executed, but in BASIC, this property does take effect.
Is this a bug?
Libre Office 7.6 on Windows 11.
wanglong
Posts: 51
Joined: Fri Sep 09, 2022 10:57 am
Location: Beijing,China

Re: .uno:GoUp "Count" property is not work for me

Post by wanglong »

And as I said, I'm having trouble executing .uno:GoUp commands in the way I use the API. So I wanted to do this by using JAVA to control LO to execute BASIC scripts, but I found that I couldn't execute BASIC scripts correctly in documents opened in hidden mode (which works in visible mode), and I'm discussing this in this topic viewtopic.php?p=544614#p544614.
Libre Office 7.6 on Windows 11.
User avatar
DiGro
Posts: 175
Joined: Mon Oct 08, 2007 1:31 am
Location: Hoorn NH, The Netherlands

Re: .uno:GoUp "Count" property is not work for me

Post by DiGro »

In Basic:

Code: Select all

Sub Move10Up()
  Dim oViewCursor As Object
  oViewCursor = ThisComponent.CurrentController.getViewCursor()
  oViewCursor.goUp(10, False)
End Sub
____________
DiGro

AOO 4.1.15 (Dutch) on Windows 11. Scanned with Ziggo Safe Online (F-Secure)
Post Reply