Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default "Run-time error 91: Object variable or With block not set"

This code is run from a VB6-application. Could someone tell my why the
line I've pointed out works first time the code is run, but fails the
second time (with error given in subj.)

Before opening kontrolkort.xls it is not opened by any other
application.

It seems xloW is Nothing, but why...I set it at the beginning?

'---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

'--alot of code-cut---

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

' ******** Error on next line *********
ActiveCell.Value = CSng(Me.List1.Text) ' <------
ActiveCell.Offset(1, 0).Activate
End With

Set xloW = Nothing
Set xlo = Nothing

'---code end

I'm not closing the excel file since I wish to keep working in it. But
as said: before this code is run the second time, the file will be
closed.

Also, after this code is run my VB-application is blinking on the
taskbar as if it's still pendling something...any ideas?


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
Runtime Error '91' Object variable or With block variable not set Alec Coliver Excel Discussion (Misc queries) 2 October 24th 09 02:29 PM
Ogilvy Help :) - "Object variable or With block variable not set" Mike Taylor Excel Programming 1 December 16th 03 07:21 AM
Error 91 - Object variable with block variable not set Jim[_35_] Excel Programming 2 November 27th 03 03:34 AM
"Run-time error '1004'" Method 'Range' of object '_global' failed. haisat[_2_] Excel Programming 0 October 20th 03 12:13 PM
Exel2000 VBA - Creating a Command Bar - Error: "Object Variable or With not Set" keepitcool Excel Programming 0 August 11th 03 12:29 PM


All times are GMT +1. The time now is 08:53 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"