Object Variable or With block variable not set error

teachman

Active Member
Joined
Aug 31, 2011
Messages
321
Hello,

Using stream.WhiteLine in a VBA script is giving me the Object variable or With block variable not set error msgbox. Clicking on the Debug button brings me to the line that is written
stream.WriteLine " "

This is happening at the end of the script. But, I've used the stream.WriteLine probably about 100 times up until this point. I DIM fso As New FileSystemObject in the first ten lines of the script. Then I Dim stream AS TextStream. Then I Set stream = fso.CreateTextFile ("C:\temp\Tech Soil Service Error.log", True).

As I've said, I probably use the streamWriteline at least 100 times before I get the Object variable or With block variable not set error msgbox.

The script is writing the stream.WriteLine to the error log file.

I've used this same construct for years and never had this issue before. I'm using Excel 2016.

Thanks,

George Teachman
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
It is obviously losing its attributes somewhere between the last place it worked and where you are getting the error. You can either post that part of the code so we can look at it, or you can use the F8 function key and step through the code to see for yourself where the variable loses its value. If at some point you delete the object that the variable represents then the value reverts to 'Nothing'.
 
Upvote 0
It is obviously losing its attributes somewhere between the last place it worked and where you are getting the error. You can either post that part of the code so we can look at it, or you can use the F8 function key and step through the code to see for yourself where the variable loses its value. If at some point you delete the object that the variable represents then the value reverts to 'Nothing'.

MrExcel seems to have changed its way of replying to a thread answer or question. So, hopefully this will work. Buried deep in the code I found a stream.Close line after which there were other stream.WriteLine commands.

I found this by using the F8 'step by step' function.

JLGWhiz, thanks for the suggestion.

Thanks,

George Teachman
 
Upvote 0
Glad you found the problem.

MrExcel seems to have changed its way of replying to a thread answer or question.

Not sure what this means, but the replies you get on the forum depends upon who responds and how they interpret the issue in the OP. All responders are volunteers who simply think they can help and some are more experienced than others, ranging from novice to professional. I have been a member of this forum for only about eight years but have not noticed any changes in in how replies are made.
 
Upvote 0
I think the problem is related to IE11. When I connect to Mr. Excel using IE over the Internet speed between me and the Mr. Excel server slows to a low baud speed. So slow that I have to physically slow down my typing. My problem may have just been another manifest station of the overall issue with IE. I tried changing to Firefox, but sometimes have the same throttled down response time. I've finally gone to Chrome.

Anyway, this group has been so helpful over the years, I really appreciate it. By the way, i'm suffering from the keyboard response time right now.

Thanks.
 
Upvote 0
I was having a similar problem with IE and found that clicking the Internet Settings and Compatibility View I could enter the offending site into a dialog box and it cleared up the jumping and jerking.
 
Upvote 0
I'll give that a try the next time I need to ask you guys some questions. And, there WILL be a next time;)

Thanks,

George Teachman
 
Upvote 0

Forum statistics

Threads
1,213,490
Messages
6,113,956
Members
448,535
Latest member
alrossman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top