Ask Your Question

How can I call a python script from a Basic macro? [closed]

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 reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-10-03 22:59:52.270573

1 Answer

Sort by » oldest newest most voted

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("$HelloWorldPython?language=Python&location=share")
    oScript.invoke(array(), array(), array())
End Sub
edit flag offensive delete link more


@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 "$HelloWorldPython (share, Python)"

librebel gravatar imagelibrebel ( 2017-05-12 22:27:20 +0200 )edit

Question Tools

1 follower


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

Seen: 1,863 times

Last updated: May 12 '17