Macros 从Writer宏打开OpenOffice电子表格
我是OpenOffice新手,我正在尝试将MS Office宏移植到OpenOffice Basic。我需要能够从Writer打开Calc电子表格,以便将其内容转储到Writer宏中的数组中。OpenOffice文档很难编写。谢谢Macros 从Writer宏打开OpenOffice电子表格,macros,openoffice.org,openoffice-basic,Macros,Openoffice.org,Openoffice Basic,我是OpenOffice新手,我正在尝试将MS Office宏移植到OpenOffice Basic。我需要能够从Writer打开Calc电子表格,以便将其内容转储到Writer宏中的数组中。OpenOffice文档很难编写。谢谢 Dim oSM Dim oSM Dim oDesk 'Instantiate OOo Set oSM = CreateObject("com.sun.star.ServiceManager") 'Create the services Set oDesk = o
Dim oSM
Dim oSM
Dim oDesk
'Instantiate OOo
Set oSM = CreateObject("com.sun.star.ServiceManager")
'Create the services
Set oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
Set oCalc = oSM.createInstance("com.sun.star.sheet.SpreadsheetDocument")
Dim strVar(4) As String
Dim iRow As Integer
Dim iColumn As Integer
Dim strEnd As String
Dim Cell as object
Dim CalcDoc
CalcDoc = oDesk.loadComponentFromURL("file:///c:/<path>", "_blank", 0, Array())
Dim Sheet
Sheet = CalcDoc.Sheets.getByName("Sheet1")
iRow = 0
Do While strEnd <> "end"
For iColumn = 0 To 4
Cell = Sheet.getCellByPosition(iColumn, iRow)
strValue = Cell.String
strVar(iColumn) = strValue
Next
'first cell contains "end" at end of spreadsheet
strEnd = Sheet.getCellByPosition(0, iRow).String
'Do something HERE with strValue row values, like use them in a search
iRow = iRow + 1
Loop
迪姆奥德克
'实例化OOo
设置oSM=CreateObject(“com.sun.star.ServiceManager”)
“创建服务
设置oDesk=oSM.createInstance(“com.sun.star.frame.Desktop”)
设置oCalc=oSM.createInstance(“com.sun.star.sheet.SpreadsheetDocument”)
作为字符串的Dim strVar(4)
Dim iRow作为整数
Dim iColumn作为整数
像绳子一样变弱
作为对象的暗淡单元
暗淡钙度
CalcDoc=oDesk.loadComponentFromURL(“file:///c:/“,”_blank“,0,数组()
暗淡的床单
Sheet=CalcDoc.Sheets.getByName(“Sheet1”)
iRow=0
边做边“结束”
对于iColumn=0到4
单元格=Sheet.getCellByPosition(iColumn,iRow)
strValue=Cell.String
strVar(iColumn)=strValue
下一个
'第一个单元格在电子表格的末尾包含“end”
strEnd=Sheet.getCellByPosition(0,iRow).String
'在此处使用strValue行值执行某些操作,例如在搜索中使用它们
iRow=iRow+1
环
希望这对某人有所帮助。我想OpenOffice Basic没有那么流行。