ingwarus
ingwarus

Reputation: 412

How check if Excel worksheet is protected?

I want to check if Excel worksheet is protected or not. I know that I can check .protectcontents, but what if worksheet is protected like this:

activesheet.protect contents:=false

.protectcontents returns false but shapes are locked. Please help.

Upvotes: 1

Views: 2518

Answers (1)

Vityata
Vityata

Reputation: 43595

The three protection properties of a worksheet are the following:

  • Sheets(1).ProtectContents
  • Sheets(1).ProtectDrawingObjects
  • Sheets(1).ProtectScenarios

You can check whether both 3 are False. If this is the case, it is not protected.

.ProtectionMode says whether "User-Interface-only" protection is turned on. You may add it to the function, if you need it. MSDN - ProtectionMode

Upvotes: 6

Related Questions