[Solved] Open Multiple Files Return Location to the Source

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Math
Posts: 89
Joined: Mon Oct 29, 2018 6:32 pm

[Solved] Open Multiple Files Return Location to the Source

Post by Math »

Greetings ,

           I need to build a button in File A with the following Macro:

           when you press the File A button, you should open a sequence of 5 new files: B, C, D, E, F

           after opening the last F file, the macro should return the location to File A, in Sheet 3, in cell F6.


thank you very much.
Last edited by Math on Fri Nov 09, 2018 4:12 pm, edited 2 times in total.
LibreOffice 5.4.4.2 on Windows 7
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Macro: Open Multiple Files and Return Location to the So

Post by Lupp »

What do you mean by "location"?

Suppose your code was started when document A was active. You then will have created a grip on that component as, say,
docA = ThisComponent. Then you opened file B with the statement
docB = StarDesktop.LoadComponentFromUrl(ConvertToUrl("Drive/Path/myFile.odx"), "_blank", 0, Array()) or similar. ...

As long as your code is running, you do everything via the interfaces you get by docA, docB and so on.
If you want to return the control to the user via the UI (interactively) simply present the respective component to him by
docA.CurrentController.Frame.Activate (Sorry. This seems not to work still in the intended way. )
docA.CurrentController.Frame.ContainerWindow.ToFront

If docA is a spreadsheet document possessing a "Sheet3" (Better no spaces in sheetnames!), and you want to present a view of this document with cell F3 of that sheet selected, you need to get access to the cell as an obect, say cellF6 by
cellF6 = docA.Sheets.GetByName("Sheet3").GetCellRangeByName("F6") e.g. and select it
docA.CurrentController.Select(cellF6)

Was this what you wanted?

Did you read a bit about the API before you started to write "macros"?
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Math
Posts: 89
Joined: Mon Oct 29, 2018 6:32 pm

Re: Macro: Open Multiple Files and Return Location to the So

Post by Math »

sr. Lupp,

           is there any BASIC command (LibreOffice) with the same effect as the command vba: Application.DisplayAlerts = False ?

           because I need to ignore the alerts of some spreadsheets.


thank you very much
LibreOffice 5.4.4.2 on Windows 7
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Macro: Open Multiple Files and Return Location to the So

Post by Lupp »

I don't know a setting which I would expect to be (about) equivalent to your VBA command. 

As I dont't know about VBA / MS Office, I have to ask you what kinds of alerts you have to expect and would like to suppress. After all, alerts aren't just thrown for fun. Ignoring one might result in a serious problem. Suppose you try to change the content of a protected cell in a protected sheet open an already opened file a second time ...
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
Math
Posts: 89
Joined: Mon Oct 29, 2018 6:32 pm

Re: Macro: Open Multiple Files and Return Location to the So

Post by Math »

sr. Lupp ,

              I inform you that your solution indicated to open several files, is working perfectly well.

              referring to the Ignore Alerts command is as follows:

              when I use your command to open multiple files, there will be some files between open files that will have alert of simple links, without much importance to consider.

              these simple alerts interrupt the continuation of the command to open the following other files, that is, the macro to open all files is interrupted by this simple alert in a given file.

              so I need a command in LibreOffice that ignores a simple alert, that is, jump over this simple alert.
LibreOffice 5.4.4.2 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Macro: Open Multiple Files and Return Location to the So

Post by Villeroy »

Pass a c.s.s.beans.PropertyValue with name "UpdateDocMode" and one value from c.s.s.document.UpdateDocMode
http://www.openoffice.org/api/docs/comm ... ateDocMode
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
Math
Posts: 89
Joined: Mon Oct 29, 2018 6:32 pm

Re: [Solved] Open Multiple Files Return Location to the Sour

Post by Math »

sr. Villeroy ,

I have not had time to do the tests yet. I'll let you know as soon as I get results.

Thank you for your attention.

hugs.
LibreOffice 5.4.4.2 on Windows 7
Post Reply