2010-11-09 42 views
2

我是OpenOffice的新手,我試圖將MS Office宏移植到OpenOffice Basic。我需要能夠從Writer打開Calc電子表格,這樣我可以將其內容轉儲到我的Writer宏中的數組中。 OpenOffice文檔非常艱難。謝謝!從編寫器宏中打開OpenOffice電子表格

回答

2
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 
+0

希望這可以幫助別人。我猜OpenOffice Basic並不是那麼受歡迎。 – 2010-11-12 05:55:35

相關問題