[Solved] Run Macro in Another File

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] Run Macro in Another File

Post by Math »

I'm looking for a macro for my A File that runs the following in LibreOffice:

        I need to press File A button to Run a macro located in the other File B.

        Note:

        1) I already have file B open.

        2) Macro name in file B is:
   
           macro: Clear everything

           library: VBAProject

           module: Module1


thank you.
Last edited by Math on Tue Nov 13, 2018 12:49 pm, edited 1 time in total.
LibreOffice 5.4.4.2 on Windows 7
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: macro: Run Macro in Another File

Post by Zizi64 »

library: VBAProject
The file "B" is an xls/xlsx type document? It will not work with AOO/LO.

Always use the international standard Open Document Formats for your important documents.
The VBA is not compatible with the StarBasic+API of the AOO/LO. You must rewrite the VBA macros for AOO/LO.

Plese upload one or two real sample document together with the embedded macros here.
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.
Math
Posts: 89
Joined: Mon Oct 29, 2018 6:32 pm

Re: macro: Run Macro in Another File

Post by Math »

sr. Zizi64,

            I previously worked with Excel files, where I had several macros in the VBAProject library of the Excel file.

            I made conversion from File.xls to File.ods, and the VBAProject library remained with the same name in the new .ods file.

            that is, the new file converted to .ODS, contains the STANDART library and also the VBAProject library.

            Can you help me create the command to run the macro in file B, using the name of this VBAProject library.

            so I'll do the tests here to see what's going to happen.


thank you very much.
LibreOffice 5.4.4.2 on Windows 7
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: macro: Run Macro in Another File

Post by Zizi64 »

I made conversion from File.xls to File.ods, and the VBAProject library remained with the same name in the new .ods file.
Delete it and use the Standard library.

Can you help me create the command to run the macro in file B, using the name of this VBAProject library.
Sorry, I can not (without a sample file and the macro code).
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.
Math
Posts: 89
Joined: Mon Oct 29, 2018 6:32 pm

Re: macro: Run Macro in Another File

Post by Math »

I was doing this in VBA Excel: Application.Run "Book1.xls! MyMacroName"

see example: https://www.rondebruin.nl/win/s9/win001.htm


hugs.
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: Run Macro in Another File

Post by Villeroy »

http://www.openoffice.org/api/docs/comm ... cript.html

Code: Select all

p = OtherDoc.getScriptProvider()
url ="vnd.sun.star.script:Standard.Module1.Main?language=Basic&location=document"
script = p.getScript(url)
ret = script.invoke( aInParam, aOutParamIndex, aOutParam)
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
User avatar
Zizi64
Volunteer
Posts: 11353
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: macro: Run Macro in Another File

Post by Zizi64 »

I was doing this in VBA Excel: Application.Run "Book1.xls! MyMacroName"
...But the AOO/LO Calc are not MS Excel, and the AOO/LO API+StarBasic are not VBA.
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.
Math
Posts: 89
Joined: Mon Oct 29, 2018 6:32 pm

Re: Run Macro in Another File

Post by Math »

Many thanks to the friends who helped me,

      I was able to find a solution on the following link:

https://ask.libreoffice.org/pt-br/quest ... -planilha/


hugs to all .
LibreOffice 5.4.4.2 on Windows 7
Post Reply