Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Runtime Error '91' Object variable or With block variable not set | Excel Discussion (Misc queries) | |||
Ogilvy Help :) - "Object variable or With block variable not set" | Excel Programming | |||
Error 91 - Object variable with block variable not set | Excel Programming | |||
"Run-time error '1004'" Method 'Range' of object '_global' failed. | Excel Programming | |||
Exel2000 VBA - Creating a Command Bar - Error: "Object Variable or With not Set" | Excel Programming |