加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

使用VB或python编写OpenOffice Forms脚本

发布时间:2020-12-17 00:11:25 所属栏目:大数据 来源:网络整理
导读:我正在尝试编写我的OpenOffice文档(在我的情况下是Writer)来编写一些简单的小部件.即我想将文本从小部件复制到小部件.为此我想获得一个组件,而不是从中获取文本. 我一直试图这样做: document = ThisComponent.CurrentController.FrameoDocument = ThisCompo
我正在尝试编写我的OpenOffice文档(在我的情况下是Writer)来编写一些简单的小部件.即我想将文本从小部件复制到小部件.为此我想获得一个组件,而不是从中获取文本.

我一直试图这样做:

document   = ThisComponent.CurrentController.Frame

oDocument      =  ThisComponent
oTextBoxFrom = document.getByName("Text Box 1")    # 1
oTextBoxFrom = oDocument.getByName("Text Box 1")   # 2

版本#1和#2都不起作用. VB编译器吐出“文本框1”无法访问,但我的表单中有该组件.我的猜测是我试图从错误的地方获取这个组件,例如.不是它的框架.我只是无法弄清楚文件的结构是什么.

这似乎是一个非常简单的任务,但是我无法找到任何OpenOffice规范,因为从VB或python访问OO UNO对象.

美好的一天.

如果你选择使用VB,你必须知道:

VBA : Compatibility between OpenOffice.org Basic and VBA relates to
the OpenOffice.org Basic language as well as the runtime library. The
OpenOffice.org API and the Dialog Editor are not compatible with VBA
(standardizing these interfaces would have made many of the concepts
provided in OpenOffice.org impossible).

如果它是python:

OpenOffice.org 3.1 ships with the Python scripting language,version
2.6.1. Older OpenOffice.org ships with Python version 2.3.4. This Python distribution comes with the Uno module,which connects the UNO
API to the python scripting language. To run this version of Python on
Linux,you can go directly to the OpenOffice.org PATH. And as one
would expect with any distribution of Python,OOo-Python can be run
from the command line as well. If you already have a separate Python
2.6 installation,you can import the uno module (the Python-UNO bridge) to it using these instructions. If you already have a
different version of Python installed on Windows,you can also access
the UNO API using the COM bridge instead of the Python bridge.
Requires the add-on pywin32 module so Python can talk to COM. Note
that while the UNO API is uniform,the implementation by the two
bridges is slightly different,so the syntax required by each is also
sometimes different.

Python UNO bridge

upd:ooobloger可能会帮助您理解python和uno集成.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读