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

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
Tenebroleso
Posts: 15
Joined: Thu Jul 05, 2012 2:58 pm

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

Post 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
Last edited by Hagar Delest on Mon Jul 16, 2012 9:59 pm, edited 1 time in total.
Reason: tagged [Solved].
OpenOffice 3.4 on Windows XP
User avatar
karolus
Volunteer
Posts: 1159
Joined: Sat Jul 02, 2011 9:47 am

Re: OpenOffice Automation with VB6 (oColumns.removeByIndex)

Post by karolus »

Hallo

Use parentheses:

Cells_DeleteColumn( MaxCol, oSheet )

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

Karo
AOO4, Libreoffice 6.1 on Rasbian OS (on ARM)
Libreoffice 7.4 on Debian 12 (Bookworm) (on RaspberryPI4)
Libreoffice 7.6 flatpak on Debian 12 (Bookworm) (on RaspberryPI4)
Tenebroleso
Posts: 15
Joined: Thu Jul 05, 2012 2:58 pm

Re: OpenOffice Automation with VB6 (oColumns.removeByIndex)

Post 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
OpenOffice 3.4 on Windows XP
Post Reply