Mar*_*lke 6 python vbscript scripting openoffice-writer
我正在尝试编写我的OpenOffice文档(在我的情况下是Writer)来编写一些简单的小部件.即我想将文本从小部件复制到小部件.为此我想获得一个组件,而不是从中获取文本.
我一直试图这样做:
document = ThisComponent.CurrentController.Frame
oDocument = ThisComponent
oTextBoxFrom = document.getByName("Text Box 1") # 1
oTextBoxFrom = oDocument.getByName("Text Box 1") # 2
Run Code Online (Sandbox Code Playgroud)
版本#1和#2都不起作用.VB编译器吐出"文本框1"无法访问,但我的表单中有该组件.我的猜测是我试图从错误的地方获取这个组件,例如.不是它的框架.我只是无法弄清楚文件的结构是什么.
这似乎是一个非常简单的任务,但是我无法找到任何OpenOffice规范,因为从VB或python访问OO UNO对象.
我没有 openoffice 脚本编写的经验,但我找到了这些示例,请注意,它们从不在文档本身上使用 getByName ,但总是在文档的某些部分上使用 getByName 。
docCalc = ThisComponent
maFeuille = docCalc.Sheets.getByName("leCSV")
....
for f = 0 to lesFamilles.Count -1' chaque famille
nomFam = lesFamilles.ElementNames(f)
uneFamille = lesFamilles.getByName(nomFam)
...
monDocument.TextTables.hasByName("Finances")
...
lesSections = monDocument.TextSections
sectA = lesSections.getByName("Aline")
Run Code Online (Sandbox Code Playgroud)
您可以在http://oqei.free.fr/echange/VBA/Programmation_OpenOffice_org_3_ed1_v1.pdf找到这个大 pdf 的其余部分,它是法语的,但代码是通用的,是吗?希望能帮助到你..