Is it possible to run openoffice macro from external file?

霸气de小男生 提交于 2019-12-06 03:26:29

问题


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

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

回答1:


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:

  • Custom OpenOffice.org Basic Macros and Libraries - OpenOffice.org Wiki
  • OpenOffice.org Forum :: Enable OpenOffice Macro through Command Line.
  • OpenOffice.org Forum :: simple command line question
  • OpenOffice.org Forum :: HowTo Run Macros from Document from Shell

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...



来源:https://stackoverflow.com/questions/5957340/is-it-possible-to-run-openoffice-macro-from-external-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!