在OpenOffice Calc中更改以编程方式打印区域

时间:2017-05-29 19:55:54

标签: openoffice-calc libreoffice-basic openoffice-basic

我正在使用vb6动态创建Calc文档。我打印时,每页需要重复1行和1列。

这是代码:

 Dim mPrintOptions(2) As Object
 Dim OO_Dispatcher As Object
 Set OO_Dispatcher = oServiceManager.createInstance("com.sun.star.frame.DispatchHelper")
 Set mPrintOptions(0) = MakePropertyValue(oServiceManager, "PrintArea", "")
 Set mPrintOptions(1) = MakePropertyValue(oServiceManager, "PrintRepeatRow", "$A$2")
 Set mPrintOptions(2) = MakePropertyValue(oServiceManager, "PrintRepeatCol", "$A$1")

 OO_Dispatcher.executeDispatch oDeskTop, ".uno:ChangePrintArea", "", 0, mPrintOptions

我已经让这段代码在保存的文档中制作了一个宏。

服务管理器和桌面对象以前是实例化的。文档正在创建中,但是当我将其发送到打印机时,我不会重复上面指定的行和列。

1 个答案:

答案 0 :(得分:0)

我在这里找到了解决方案:

https://wiki.openoffice.org/wiki/ES/Manuales/GuiaAOO/TemasAvanzados/Macros/StarBasic/TrabajandoConCalc/Imprimiendo

我的代码终于如此:

Dim OO_TitulosR As Object
Dim OO_ActiveSheet As Object
Set OO_TitulosR = OO_Document.Bridge_getStruct("com.sun.star.table.CellRangeAddress")
Set OO_ActiveSheet = OO_Document.getCurrentController.getActiveSheet
OO_TitulosR.StartColumn = 0
OO_TitulosR.EndColumn = 0
OO_TitulosR.StartRow = 1
OO_TitulosR.EndRow = 1
OO_ActiveSheet.setTitleColumns OO_TitulosR
OO_ActiveSheet.setTitleRows OO_TitulosR