Error "The object invoked has disconnected from its clients." when setting RowHeight using Excel OLE Automation

Posted on 2005-03-24
Medium Priority
Last Modified: 2010-05-02
I have a VB 6.0 project that contains code to generate an Excel report.  The report has been working well for a long time; however, I am now getting the following error:

The object invoked has disconnected from its clients.
err.number = -2147417848

The line kicking the error reads:

oSheet.Rows("3:3").RowHeight = 77.25

Where oSheet is declared as follows:

Set oXL = CreateObject("Excel.Application")
Set oBook = oXL.Workbooks.Add()
Set oSheet = oBook.Sheets(1)

This is a showstopper.  If anyone has any ideas I would be greatly appreciative.
Question by:tlchavet
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 12

Expert Comment

ID: 13624022
Is Excel installed locally or are you accessing via LAN?

Is the line that bombs tyhe first  line thgat uses the oSheet object call?

Does it always bomb at that line?

Author Comment

ID: 13624107
Excel is installed locally.

This is not the first call to oSheet.  There are a bunch of column width sets first.

Yes, it always bombs at that line.
LVL 38

Expert Comment

ID: 13624307
Doesn't look like this:

It's late bound so it shouldn't be this:

Unless you have a reference to Excel in your project as well... If you do try removing it and recompiling.

More information on the code that precedes the error may help


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

LVL 10

Expert Comment

ID: 13625891
Hi, tlchavet.

I've gotten that error when my ADO connection object has been shut down and an attempt is made to read from/write to my db.  It's likely that at the point in your code where you get the error, something is causing either your oXL, oBook, or oSheet objects to shut down.  If you scan all code in your application for the code you use to disconnect/shut down any of these objects (e.g. "= nothing", "quit", etc.), you may find the code that is unloading your object.  Barring that, what happens if you rem out the code that crashes your app (e.g. "oSheet.Rows("3:3").RowHeight = 77.25
")?  If the very next line of code bombs out during your next run, it's likely the error is caused just prior to that line.  If your app runs fine after remming out, then we need to look at your Excel sheet's code at 3:3.

Author Comment

ID: 13626382
If I resume next after the error, the rest of the report runs fine.

Author Comment

ID: 14365312
This one can be closed with no solution.

Accepted Solution

modulo earned 0 total points
ID: 14395797
PAQed with points refunded (500)

Community Support Moderator

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question