Excel VBA Automation Error: The object invoked has disconnected from its clients Excel VBA Automation Error: The object invoked has disconnected from its clients vba vba

Excel VBA Automation Error: The object invoked has disconnected from its clients


I have had this problem on multiple projects converting Excel 2000 to 2010. Here is what I found which seems to be working. I made two changes, but not sure which caused the success:

1) I changed how I closed and saved the file (from close & save = true to save as the same file name and close the file:

...    Dim oFile           As Object       ' File being processed...[Where the error happens - where aArray(i) is just the name of an Excel.xlsb file]   Set oFile = GetObject(aArray(i))...'oFile.Close SaveChanges:=True    - OLD CODE WHICH ERROR'D'New CodeoFile.SaveAs Filename:=oFile.NameoFile.Close SaveChanges:=False

2) I went back and looked for all of the .range in the code and made sure it was the full construct..

Application.Workbooks("workbook name").Worksheets("worksheet name").Range("G19").Value

or (not 100% sure if this is correct syntax, but this is the 'effort' i made)

ActiveSheet.Range("A1").Select


I have just met this problem today: I migrated my Excel project from Office 2007 to 2010. At a certain point, when my macro tried to Insert a new line (e.g. Range("5:5").Insert ), the same error message came. It happens only when previously another sheet has been edited (my macro switches to another sheet).

Thanks to Google, and your discussion, I found the following solution (based on the answer given by "red" at answered Jul 30 '13 at 0:27): after switching to the sheet a Cell has to be edited before inserting a new row. I have added the following code:

'=== Excel bugfix workaround - 2014.08.17Range("B1").ActivatevCellValue = Range("B1").ValueRange("B1").ClearContentsRange("B1").Value = vCellValue

"B1" can be replaced by any cell on the sheet.


You must have used the object, released it ("disconnect"), and used it again. Release object only after you're finished with it, or when calling Form_Closing.