Ask Your Question
0

How can I call a python script from a Basic macro?

asked 2017-05-12 19:52:50 +0200

EasyTrieve gravatar image

updated 2017-05-12 19:53:15 +0200

If you have a document with some macros, one basic and one python (if this is even possible), can anyone provide an example of how to call something like a python HelloWorld script from a basic SUB or FUNCTION?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
2

answered 2017-05-12 22:07:24 +0200

librebel gravatar image

Hello @EasyTrieve, this works for me:

Sub Call_HelloWorld
    Dim oScriptProvider, oScript
    oScriptProvider = ThisComponent.getScriptProvider()
    oScript = oScriptProvider.getScript("vnd.sun.star.script:HelloWorld.py$HelloWorldPython?language=Python&location=share")
    oScript.invoke(array(), array(), array())
End Sub
edit flag offensive delete link more

Comments

@librebel Thanks for share. The wiki doesn't list that and I've been using user and document. Don't think I really need it, but good to know. So far in early going don't see much need to call from basic.

Ratslinger gravatar imageRatslinger ( 2017-05-12 22:15:22 +0200 )edit

yw @Ratslinger, i also noticed it for the first time when setting the python macro in a buttton Execute action event, and it was displayed as "HelloWorld.py$HelloWorldPython (share, Python)"

librebel gravatar imagelibrebel ( 2017-05-12 22:27:20 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-05-12 19:52:50 +0200

Seen: 1,151 times

Last updated: May 12 '17