How can grid to libre office ?
Did not quite catch your question. What do you mean by that? Do you want to display something in VB6 application and then export it to LibreOffice format? Is that it?
Yes.
i am find this code. But not work libreoffice
openoffice its work. how does this code libreoffice ? sorry my english very bad
Public Sub ExportGridToCalc(grdTemp As MSFlexGrid, _
strTitle As String, _
Optional lngStartRow As Long = -1, _
Optional lngEndRow As Long = -1, _
Optional lngStartCol As Long = -1, _
Optional lngEndCol As Long = -1)
Dim oSM As Object REM # Object for accessing OpenOffice
Dim oDesk As Object REM # Objects from the API
Dim oDoc As Object REM # Objects from the API
Dim oSheet As Object REM # Objects from the API
Dim arg() REM # Ignore it for the moment !
Dim lngRow As Long
Dim lngCol As Long
REM # -->SET FIRST THE ROWS AND COLS
If lngStartRow = -1 Then lngStartRow = 1
If lngEndRow = -1 Then lngEndRow = grdTemp.Rows - 1
If lngStartCol = -1 Then lngStartCol = 0
If lngEndCol = -1 Then lngEndCol = grdTemp.Cols - 1
REM # Instanciate OOo : this line is mandatory with VB for OOo API
Set oSM = CreateObject("com.sun.star.ServiceManager")
REM # Create the first and most important service
Set oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
REM # Create a new doc
Set oDoc = oDesk.loadComponentFromURL("private:factory/scalc", "_blank", _
0, arg())
REM # Get the first sheet in the doc
Set oSheet = oDoc.getSheets().getByIndex(0)
Call oSheet.getCellByPosition(0, 0).setString(strTitle)
For lngRow = lngStartRow To lngEndRow
For lngCol = lngStartCol To lngEndCol
Call oSheet.getCellByPosition(lngCol, lngRow + _
IIf(lngStartRow = 0, 2, 1)).setString(grdTemp.TextMatrix(lngRow, _
lngCol))
Next
Next
Hi @xfighter9, I did my best to reformat your code so it would be easy to read with syntax-highlighting.
It looks like there might be at least one typo at “IIf(lngStartRow”