Page 1 of 1

[Solved] AOO Automation with VB6 (oColumns.removeByIndex)

Posted: Mon Jul 16, 2012 2:09 pm
by Tenebroleso
Finally the program works, thanks to you all! :)

I have a new problem now...

Code: Select all

Private sub MySub
   [...]
   MaxCol = Cells_RecoverLastColumn(oSheet) + 1 --> OK!
   Cells_DeleteColumn MaxCol, oSheet --> Don't work...
   [...]
End sub

Public Function Cells_RecoverLastColumn(oSheet As Object) As Long
    Dim oCell       As Object
    Dim oCursor     As Object
    Dim vAddress    As Variant
    
    Set oCell = oSheet.GetCellbyPosition(0, 0)
    Set oCursor = oSheet.CreateCursorByRange(oCell)
    oCursor.GotoEndOfUsedArea (True)
    Set vAddress = oCursor.RangeAddress
    Cells_RecoverLastColumn = vAddress.EndColumn
End Function

Public Sub Cells_DeleteColumn(iColumn As Long, oSheet As Object, Optional nColumns As Long = 1)
    oSheet.oColumns.removeByIndex iColumn - 1, nColumns
End Sub

Re: OpenOffice Automation with VB6 (oColumns.removeByIndex)

Posted: Mon Jul 16, 2012 2:24 pm
by karolus
Hallo

Use parentheses:

Cells_DeleteColumn( MaxCol, oSheet )

oSheet.oColumns.removeByIndex( iColumn - 1, nColumns )

Karo

Re: OpenOffice Automation with VB6 (oColumns.removeByIndex)

Posted: Mon Jul 16, 2012 2:40 pm
by Tenebroleso
Uff... solved...

Code: Select all

Public Sub Cells_DeleteColumn(iColumn As Long, oSheet As Object, Optional nColumns As Long = 1)
    Dim oColumns    As Object
    
    Set oColumns = oSheet.getColumns
    
    oColumns.removeByIndex iColumn - 1, nColumns
End Sub