从 Writer 宏打开 OpenOffice 电子表格
Posted
技术标签:
【中文标题】从 Writer 宏打开 OpenOffice 电子表格【英文标题】:Open an OpenOffice Spreadsheet from a Writer Macro 【发布时间】:2010-11-09 19:53:19 【问题描述】:我是 OpenOffice 的新手,我正在尝试将 MS Office 宏移植到 OpenOffice Basic。我需要能够从 Writer 中打开 Calc 电子表格,以便将其内容转储到 Writer 宏中的数组中。 OpenOffice 文档很难运行。谢谢!
【问题讨论】:
【参考方案1】: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
【讨论】:
希望这对某人有所帮助。我猜 OpenOffice Basic 没那么流行。以上是关于从 Writer 宏打开 OpenOffice 电子表格的主要内容,如果未能解决你的问题,请参考以下文章