Ask Your Question
0

Visual Basic 6 Flexgrid export to Libre Office [closed]

asked 2013-02-12 12:58:24 +0200

xfighter9 gravatar image

updated 2013-06-15 00:36:40 +0200

manj_k gravatar image

How can grid to libre office ?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2015-10-21 18:20:29.035414

2 Answers

Sort by » oldest newest most voted
0

answered 2013-02-12 16:11:19 +0200

victorwestmann gravatar image

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?

edit flag offensive delete link more
0

answered 2013-02-12 17:47:50 +0200

xfighter9 gravatar image

updated 2013-02-12 18:37:01 +0200

qubit gravatar image

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
edit flag offensive delete link more

Comments

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"

qubit gravatar imagequbit ( 2013-02-12 18:39:11 +0200 )edit

Question Tools

Stats

Asked: 2013-02-12 12:58:24 +0200

Seen: 1,632 times

Last updated: Jun 15 '13