Run-time error after converting from Office 2003 to Office 2010

tmStuder

New Member
Joined
Jul 21, 2011
Messages
6
I have a fine that I have been using since 2007. Yesterday we converted to Office 2010 and now some macros are not working. I get the following error:
Run-time error '-2147417848 (8001010)':
Automation error
The object invoked has disconnected from its clients.

When I debug is breaks here (the red text is highlighted):
ws.rows("2:2").Copy
ws.rows("3:3").Insert shift:=xlDown
ws.rows("3:3").EntireRow.Hidden = False

I have searched and searched and can find nothing helpful. This code runs fine in both Excel 2003 and 2007 but blows up in 2010.

Please help I think I'm going crazy!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Do you have any controls on that sheet?
 
Upvote 0
Public Sub DataRecordFind(ByRef rng As Range, batchNumber As Integer)
Dim wslog As Worksheet
Dim ws As Worksheet
Dim rngData As Range 'used to see if we have a good time field
Dim firstHit As String

Set wslog = Worksheets("Roasting Log")
Set ws = Worksheets("RoastingTime")

Set rng = Nothing

'need to find a record for this date and batch number
Set rngData = ws.Range("A:A").Find( _
what:=wslog.Range("RoastingDate"), lookat:=xlWhole)

If Not rngData Is Nothing Then

'used to determine when to stop searching
firstHit = rngData.Address

Do
'see if this record matches the batch number
If rngData.Range("B1") = batchNumber Then
'found the match for this date and batch number
Set rng = rngData
Exit Sub
End If

'search date column for next matching record
Set rngData = ws.Range("A:A").FindNext(rngData)

Loop While rngData.Address <> firstHit

End If

'couldn't find a record so create a record for this batch number
ws.rows("2:2").Copy
ws.rows("3:3").Insert Shift:=xlDown
ws.rows("3:3").EntireRow.Hidden = False

Set rng = ws.Cells(3, 1)

'roasting date
rng.Range("A1") = wslog.Range("RoastingDate")
'batch number
rng.Range("B1") = batchNumber
'formula for time between batches
' rng.Range("L1").Formula = "=I3-J4"

End Sub
 
Upvote 0
Does the code compile OK in 2010?
 
Upvote 0
Curious. Does it make any difference if you use:
Code:
ws.rows("3:3").Insert Shift:=xlDown
ws.rows("3:3").EntireRow.Hidden = False
ws.rows("2:2").Copy ws.Range("A3")
 
Upvote 0
Damned if I know - it was just a hunch. (I've never really trusted that implicit paste in the Copy then Insert routine)
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,738
Members
452,940
Latest member
Lawrenceiow

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