The Object Invoked has Disconnected from it's clients.........

Pauljj

Well-known Member
Joined
Mar 28, 2004
Messages
2,046
I have seen many posts about this error message but all seem to have different causes and solutions. Mine happens randomly, it's used to happen over a year ago and then stopped and has randomly started up again, ie sometimes the macro works without fault and other times it does't.
Code:
Option Explicit

Private Sub WORKBOOK_BEFORESAVE(ByVal SAVEASUI As Boolean, Cancel As Boolean)

Application.ScreenUpdating = False


Worksheets("Millionaires").Activate

Range("C6:V842").Select

Selection.Sort Key1:=Range("D6"), Order1:=xlDescending, Header:=xlNo, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
        
    Range("C2").Select
    Selection.ClearContents
    
ActiveWorkbook.ResetColors

ActiveWorkbook.Colors(52) = RGB(255, 128, 128)


Application.ScreenUpdating = True



End Sub
 
Last edited by a moderator:

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Pretty hard to debug a random error, but I'd change your code to:
Code:
Private Sub WORKBOOK_BEFORESAVE(ByVal SAVEASUI As Boolean, Cancel As Boolean)

Application.ScreenUpdating = False

With ThisWorkbook.Worksheets("Millionaires")

.Range("C6:V842").Sort Key1:=.Range("D6"), Order1:=xlDescending, Header:=xlNo, _
        OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
        DataOption1:=xlSortNormal
        
    .Range("C2").ClearContents
   End With
ThisWorkbook.ResetColors
ThisWorkbook.Colors(52) = RGB(255, 128, 128)
Application.ScreenUpdating = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

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