2017-05-29 120 views
1

我正在用vb6快速創建一個Calc文檔。當我打印時,我需要在每頁中重複1行和1列。在OpenOffice Calc中以編程方式更改打印區域

這是代碼:

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 

我有了這個代碼保存的文檔中作出的宏。

服務管理器和桌面對象先前已實例化。文檔創建正常,但是當我將它發送到打印機時,我不重複上面指定的行和列。

回答

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