Calc cells spreadsheet access XSheet getCellByPosition XNAmeAccess getByName XCell getValue getString getString getFormula setValue setString setFormula Sasa Kelecevic Andrew Pitonyak Laurent Godard Michael Hoennig Tom Schindl How can the cells of a given OOo/Calc document be accessed? Set objServiceManager = CreateObject("com.sun.star.ServiceManager") Set objDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop") Dim args() Set objCalcDocument = objDesktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, args) Set objSheets = objCalcDocument.Sheets aCell=???

Cells can be accessed via the sheet in which they are: objSheets.getByName("TheSheetName").

'Print Cell Value, String, Or Formula '****************************************************************** 'Author: Sasa Kelecevic 'email: scat@teol.net Sub ExampleGetValue Dim oDocument As Object, oSheet As Object, oCell As Object oDocument=ThisComponent oSheet=oDocument.Sheets.getByName("Sheet1") oCell=oSheet.getCellByPosition(0,0) 'A1 print oCell.getValue 'print oCell.getString 'print oCell.getFormula End sub 'Set Cell Value, Format, String, Or Formula '****************************************************************** 'Author: Sasa Kelecevic 'email: scat@teol.net Sub ExampleSetValue Dim oDocument As Object, oSheet As Object, oCell As Object oDocument=ThisComponent oSheet=oDocument.Sheets.getByName("Sheet1") oCell=oSheet.getCellByPosition(0,0) 'A1 oCell.setValue(23658) 'oCell.NumberFormat=2 '23658.00 'oCell.setString("oops") 'oCell.setFormula("=FUNCTION()") 'oCell.IsCellBackgroundTransparent = TRUE 'oCell.CellBackColor = RGB(255,141,56) End Sub
Modified to match new snippet-DTD Intial release