Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2 Label Options - Forms Object vs Control Box Object Awrex Excel Discussion (Misc queries) 3 July 17th 09 07:10 PM
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
Range object to Array object conversion Myrna Larson[_2_] Excel Programming 1 August 1st 03 02:27 AM
Range object to Array object conversion Alan Beban[_3_] Excel Programming 0 August 1st 03 01:24 AM
Range object to Array object conversion Tom Ogilvy Excel Programming 0 August 1st 03 12:16 AM


All times are GMT +1. The time now is 03:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"