Option Explicit Private Sub cmdTry_Click() ' makeExcel Dim cn As ADODB.Connection Dim rs As ADODB.Recordset Dim sql As String sql = "Select * from try" Set cn = New ADODB.Connection cn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};DATABASE=foo;SERVER=localhost;UID=root;" cn.Open Set rs = New ADODB.Recordset rs.Open sql, cn, adOpenForwardOnly, adLockReadOnly Do Until rs.EOF MsgBox rs!Name rs.MoveNext Loop End Sub Public Sub makeWord() Dim objManager As Object Dim objDesktop As Object Dim objText As Object Dim objCursor As Object Dim objDocument As Object Dim fname As String Dim args() Dim noArgs(1) ReDim args(0) Set objManager = CreateObject("com.sun.star.ServiceManager") Set objDesktop = objManager.createInstance("com.sun.star.frame.Desktop") 'Open a new empty writer document Set args(0) = objManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue") args(0).Name = "Hidden" args(0).Value = True 'Set Document = Desktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, args) Set objDocument = objDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0, args) 'Create a text object Set objText = objDocument.GetText 'Create a cursor object Set objCursor = objText.createTextCursor 'Inserting some Text objText.insertString objCursor, "The first line in the newly created text document." & vbLf, False 'put all this back in to run creating it ReDim Preserve args(1) fname = "file:///c:/oo_try.doc" Set args(1) = objManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue") args(1).Name = "FilterName" args(1).Value = "MS Word 97" Call objDocument.storeAsURL(fname, args) Call objDocument.Close(False) Call objDesktop.Terminate 'end of put back in MsgBox "Done" End Sub Public Sub makeExcel() Dim objManager As Object Dim objDesktop As Object Dim oCell As Object Dim oSheets As Object Dim oSheet As Object Dim objDocument As Object Dim fname As String Dim args() Dim noArgs(1) ReDim args(0) Dim nCols As Long, nRows As Long, eSumFunc As Long, eAvgFunc As Long, nSum As Long, nAvg As Long Dim n As Long Set objManager = CreateObject("com.sun.star.ServiceManager") Set objDesktop = objManager.createInstance("com.sun.star.frame.Desktop") 'Open a new empty writer document Set args(0) = objManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue") args(0).Name = "Hidden" args(0).Value = True 'Set Document = Desktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, args) Set objDocument = objDesktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, args) 'Set oSheets = objDocument.Sheets() 'Set oSheet = oSheets.getByIndex(0) Set oCell = GetCell(objDocument, 0, 0, 0) oCell.Value = 200 Set oCell = GetCell(objDocument, 0, 0, 1) oCell.Value = 300 Set oCell = GetCell(objDocument, 0, 0, 2) oCell.Formula = "=Sum(A1:A2)" 'put all this back in to run creating it ReDim Preserve args(1) fname = "file:///c:/oo_try.xls" Set args(1) = objManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue") args(1).Name = "FilterName" args(1).Value = "MS Excel 97" Call objDocument.storeAsURL(fname, args) Call objDocument.Close(False) Call objDesktop.Terminate 'end of put back in MsgBox "Done" End Sub Public Function GetCell(oDocument As Object, nSheet As Long, nColumn As Long, nRow As Long) _ As Object Dim oSheets As Object Dim oSheet As Object Set oSheets = oDocument.Sheets() Set oSheet = oSheets.getByIndex(nSheet) Set GetCell = oSheet.getCellByPosition(nColumn, nRow) End Function