[Solved] AOO Automation with VB6 (oColumns.removeByIndex)
Posted: Mon Jul 16, 2012 2:09 pm
Finally the program works, thanks to you all!
I have a new problem now...
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