

OSheet = oDoc.getSheets().getByIndex(0) ‘Get first sheetĬ.gotoEndOfUsedArea(False) ‘Points cursor to the end of the used area, parm sets cursor size to single cell OProcess = Process.GetProcessesByName ("SOffice.bin") ‘Tidy up in case of partially opened/hanging OO instance ODoc = oDesk.loadComponentFromURL ("file:///C:/Users/Public/Documents/Test/OD_Test.ods", "_blank", 0, arg) ‘Open an existing doc, note no index on arg parameter ODesk = oSM.createInstance (".Desktop") ‘Create service

OSM = CreateObject ("") ‘Instantiate Open Office for VB Close the programs, wait for a short while and re-try.") MsgBox("Unable to proceed whilst other Open Office programs are running. OOProcess = Process.GetProcessesByName ("SOffice") Unlike the MSOfficeExcel example it cannot work if other instances of the application are open, in which case it will notify and back out.ĭim oSM ‘Root object for accessing OpenOffice from VBĭim oDesk, oDoc As Object ‘First objects from the APIĭim arg(1) As Object ‘Used as parameter in opening docĬheck to see if OO instance open anywhere, if so notify and back out The process opens the worksheet, finds the first completely empty row and inserts values into a row of cells, saves the OpenOffice Calc sheet and closes the whole application. The following code in VB.Net shows how to open, update, and close an existing OpenOffice Calc sheet. Unlike MS Office automation where quitting / closing the class object and setting it to nothing clears the application from the process stack, OpenOffice has a tendency to loiter about especially with a stubborn. Most of the references I have come across for updating Open Office with VB.Net do not cover closing the application (or in some cases opening) completely. Update Open Office Calc Spreadsheet in VB.Net
