Is it possible to run openoffice macro from extern

2019-04-09 17:37发布

I want to run OpenOffice macro from external file. Like:

vlad@leo ~ $ soffice macro:///home/vlad/q.vbs 

1条回答
别忘想泡老子
2楼-- · 2019-04-09 18:08

Not really an answer - just a comment instead, so as to bump this question, and hopefully get an answer :)

This possibly has to do with having to explicitly set permissions for macros, for instance:

Can't execute macro from command line (View topic) • OpenOffice.org Community Forum

Edit: In fact it seems to be impossible to call document macros, which is perfect for security reasons.

See also:

As a side note, the standard Module1 file can be found in (on Linux):

~/.openoffice.org/3/user/basic/Standard/Module1.xba
~/.libreoffice/3/user/basic/Standard/Module1.xba

and note that the .xba is actually an XML file, that contains the Basic macro source, as in:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Module1" script:language="StarBasic">REM  *****  BASIC  *****

Sub Main

End Sub</script:module>

Unfortunately, just copying to the respective directories (below, in extensions) does not work, as in the following command line snippet..

sudo mkdir /usr/lib/libreoffice/share/extensions/mytest
sudo cp ~/.libreoffice/3/user/basic/Standard/Module1.xba /usr/lib/libreoffice/share/extensions/mytest/MyTestModule.xba
sudo sed -i 's/Module1/MyTestModule/g' /usr/lib/libreoffice/share/extensions/mytest/MyTestModule.xba

So I guess the only way is to manually add/allow Macros in OpenOffice, and then possibly find where the respective .xba's are stored, and change their code there (if only a command line usage is desired)...

Maybe using Python - OpenOffice.org Wiki is more open approach to external scripts - but it requires that you start openoffice as a server...

查看更多
登录 后发表回答