object invoked has disconnected from its clients

kaywin

New Member
Joined
Nov 23, 2010
Messages
30
For one column we have used addType validation. Below is the syntax we have used.
.Add Type:=xlValidateWholeNumber, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:="0", Formula2:="999999999999999999"

The same is working fine when we don't protect the sheet. However for project constraints we are protecting the workbook & the work sheet due to which we are getting the error as below.

object invoked has disconnected from its clients.

Please help us to inorder to overcome the above mentioned error.

Thanks & Regds
Kaywin
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Can you show the code that does the protecting?

In what order do your tasks take place? ( I mean, do you try to add data validation after applying protection? )
 
Upvote 0
We are not protecting the sheet thro VBA code...we are protecting workbook and sheet from Tools->Protection..

First we have added the Data validation through vba code...then we protected the sheet..

After protecting the sheet,this data validation is not working.. its throwing error in .AddType

Thanks
 
Upvote 0
How is it that your code is running after you apply protection exactly? You say "First we have added the Data validation through vba code", so why is your code trying to run again later?
 
Upvote 0
Has anyone discovered a solution to this problem? I have pretty much the exact same issue (VBA code running fine until protecting the worksheet using Tools>Protection, error on line .AddType, 'object invoked disconnected from its clients'). Any help much appreciated =)
 
Upvote 0
Typical, as soon as I post somewhere for help I find a solution!

To anyone who is interested, this is the code I used to get it working:

For Each sh In ActiveWorkbook.Worksheets
sh.Unprotect
Next sh

With Selection.Validation
...
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:=xlBetween, Formula1:=list
....
End With

For Each sh In ActiveWorkbook.Worksheets
sh.Protect
Next sh
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,241
Members
449,075
Latest member
staticfluids

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