Why 'Unprotect' works for 2003 but not 2000?!
Hi Frank,
With xl2k, in order to insert rows on a protected sheet there are two
options:
(1) Unprotect the sheet, insert the required row(s) and then reprotect
the sheet.
(2) Set the Protect method's UserInterfaceOnly parameter to true. This
enables VBA manipulation of the protected sheet, including the insertion of
rows.
However, this setting is not persistent and needs to be reset each time the
workbook is opened.
Perhaps, therefore, you could set protection in the Workbook_Open or
Auto_Open procedures, e.g.:
'=============
Sub Auto_Open()
With Worksheets("Sheet1")
.Protect Password:="drowssap", UserInterfaceOnly:=True
End With
End Sub
'<<=============
As you have discovered, protection functionality is increased in xl2003. If
an application is to be used with different versions of Excel, it is
necessary to restrict the functionality to that which is available with the
oldest version likely to be used.
---
Regards,
Norman
"OrientalPearl" wrote in message
oups.com...
Hi all,
Maybe it's a kinda stupid question...but Im frustrated to get this
sorted!
Basically I created a workbook with sheets protected, which also
involves some macros behind. It works perfectly in Excel 2003, but it
fires run-time error 1004:
You cannot sue this command on a protected sheet. To unprotect the
sheet, use the Unprotect Sheet command...(rest omitted)
In debugging, the following line was focused:
Selection.Insert Shift :=xlDown
Apparently such an insertion attempt is not allowed(?). I have
unprotected the current sheet far at the beginning using:
masterworkbook.Sheets("Shipper").Unprotect Password:="MyPIN"
So can anyone tell why this does not work in Excel 2000(it does for
Excel 2003)? How can the insertion be done legitimately in Excel 2000
then?
Thanks in advance to any response!!
Regards
Frank
|