View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default R/T 1004 - Unable to get Button prop of Ws Class

That means that the buttons are not named Protect WB and Unprotect WB.Select
them, and overwrite the names in the Names box.

Wouldn't it be better to make them visible/non-visible, as disabled has no
identifying features?

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Jim May" wrote in message
...
I have a file (Sheet1 only used) with two Forms Command Buttons, with
Captions ToProtectWB and ToUnprotectWB. I want one to be enabled
and the other disabled according to the current setting. This is what I
now
have **which is producing R/T 1004**. Can someone assist me?

Sub ToProtectWB()
'
ActiveWorkbook.Protect Password:="password", Structu=True,
Windows:=False
Sheets(1).Buttons("Protect WB").Enabled = False
Sheets(1).Buttons("Unprotect WB").Enabled = True
End Sub
Sub ToUnprotectWB()
'
ActiveWorkbook.Unprotect Password:="password"
Sheets(1).Buttons("Unprotect WB").Enabled = False
Sheets(1).Buttons("Protect WB").Enabled = True
End Sub