Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Help with the Excel-object
I've got a VB6-application with a command button, which holds this
code: '---code begin Dim xlo As excel.Application Dim xloW As excel.Workbook Dim myCount As Integer, x As Integer, NewMeasure As Integer Dim isEven As Boolean Set xlo = New excel.Application Set xloW = xlo.Workbooks.Open("u:\excel\kontrolkort.xls") xloW.Application.Visible = True xloW.Worksheets(1).Range("G42").Value = Me.Antal_n ' List1.ListIndex = 0 For x = 0 To List1.ListCount - 1 List1.ListIndex = x If Left(List1.Text, 1) < "-" Then myCount = myCount + 1 Next x xloW.Worksheets(1).Range("B15").Activate isEven = False For x = 0 To List1.ListCount - 1 List1.ListIndex = x If Left(List1.Text, 1) < "-" Then With xloW.Worksheets(1) If NewMeasure = CInt(Me.Antal_n) Then If isEven = False Then ActiveCell.Offset(11 - (CInt(Me.Antal_n) - 1), 0).Activate NewMeasure = 0 isEven = True Else ActiveCell.Offset(-(11 + (CInt(Me.Antal_n) + 1)), 1).Activate NewMeasure = 0 isEven = False End If End If ActiveCell.Value = CSng(Me.List1.Text) ' <------ ActiveCell.Offset(1, 0).Activate End With NewMeasure = NewMeasure + 1 End If Next x Set xloW = Nothing Set xlo = Nothing '---code end The first time I run the procedure it does it work well. But the second time it stops on "ActiveCell.Value = CSng(Me.List1.Text)" with error message "Run-time error 91: Object variable or With block not set" Why does it open xls-file and insert data well the first time, but then it fails? Thanks in advance! Regards, Snedker |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
2 Label Options - Forms Object vs Control Box Object | Excel Discussion (Misc queries) | |||
Object Variable Not Set Error on Selection object | Excel Worksheet Functions | |||
Range object to Array object conversion | Excel Programming | |||
Range object to Array object conversion | Excel Programming | |||
Range object to Array object conversion | Excel Programming |