[Solved] Open Multiple Files Return Location to the Source

Creating a macro - Writing a Script - Using the API

[Solved] Open Multiple Files Return Location to the Source

Postby Math » Thu Nov 08, 2018 3:37 pm

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.
OpenOffice 4.1.5 on Windows 7
Math
 
Posts: 33
Joined: Mon Oct 29, 2018 6:32 pm

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

Postby Lupp » Thu Nov 08, 2018 5:05 pm

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 6.1 and older versions, PortableOpenOffice 4.1.5 and older, StarOffice 5.2
---
Let's create a powerful UFO: United Free Office!
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 2101
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

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

Postby Math » Thu Nov 08, 2018 7:17 pm

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
OpenOffice 4.1.5 on Windows 7
Math
 
Posts: 33
Joined: Mon Oct 29, 2018 6:32 pm

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

Postby Lupp » Fri Nov 09, 2018 1:37 am

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 6.1 and older versions, PortableOpenOffice 4.1.5 and older, StarOffice 5.2
---
Let's create a powerful UFO: United Free Office!
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 2101
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

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

Postby Math » Fri Nov 09, 2018 1:13 pm

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.
OpenOffice 4.1.5 on Windows 7
Math
 
Posts: 33
Joined: Mon Oct 29, 2018 6:32 pm

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

Postby Villeroy » Fri Nov 09, 2018 3:19 pm

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, OpenOffice 4.x & LibreOffice 6.x
User avatar
Villeroy
Volunteer
 
Posts: 25839
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

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

Postby Math » Sat Nov 10, 2018 11:06 pm

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.
OpenOffice 4.1.5 on Windows 7
Math
 
Posts: 33
Joined: Mon Oct 29, 2018 6:32 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 3 guests