I need a macro that changes the cursor position from File 1 to File 2, that is, jump from file 1 to file 2 .
I'm trying to use the code suggested by mr. FJCC in topic: viewtopic.php?f=45&t=87507
but "NO" is working for me.
Did I do something wrong?
Note:
1) the two files (1 and 2) are already open
2) the new cursor position should go to File 2, in Sheet3, in cell D2
hugs.
[Solved] Change cursor position from File 1 to File 2
[Solved] Change cursor position from File 1 to File 2
Last edited by Math on Tue Nov 13, 2018 5:43 pm, edited 1 time in total.
LibreOffice 5.4.4.2 on Windows 7
Re: Change cursor position from File 1 to File 2
I suggest you: If you want control more than one document - by your macro, then it is better to place the macro routines into the MyMacros/Standard library, instead of the documents. Then you will able to control all of the documents, what you can get by the macro.
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.
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.
Re: Change cursor position from File 1 to File 2
Possibly you don't have to do this. You can manipulate the document programmatically without any focus anywhere as long as the document is loaded.
This gets a reference OtherDoc, loading the document if needed.
Now you can do anything you want with the cell, the sheet, the document without using any cursor at all.
If you want to show something to the user by selecting the cell in that document:
https://wiki.openoffice.org/wiki/Docume ... nvironment
And yes, listen to what Zizi64 says. A global macro may be the better design choice in this case.
Code: Select all
OtherDoc = StarDesktop.loadComponentFromURL(url, "_default", 0, Array)
sh = OtherDoc.Sheets.getByName("Sheet3")
cell = sh.getCellByPosition(3, 1)
Now you can do anything you want with the cell, the sheet, the document without using any cursor at all.
If you want to show something to the user by selecting the cell in that document:
Code: Select all
view = OtherDoc.getCurrentController()
frame = view.getFrame()
win = frame.getContainerWindow()
frame.activate() 'frame takes focus now
win.toFront() 'visibly on top
view.setActiveSheet(sh) 'activate sheet
view.select(cell)
And yes, listen to what Zizi64 says. A global macro may be the better design choice in this case.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: Change cursor position from File 1 to File 2
thank you very much mr. Villeroy, your macro worked perfectly .
also thank mr. Zizi64 by contribution .
hugs.
also thank mr. Zizi64 by contribution .
hugs.
LibreOffice 5.4.4.2 on Windows 7