Excel 2003 Userinterfaceonly Password Protection Problem

M

marcduke98

Hi,

I have developed applications in Excel 2000. From testing these
applications in Excel 2003, it appears that the vba password protection
userinterface only switch may work only when manipulating the
activesheet. Here is simple code from a test workbook:

For the Workbook_Open event:

For Each Sh in ThisWorkbook.Worksheets
Sh.Protect "YOURPASSWORD", userinterfaceonly:=True
Next Sh

In a module:

Sub TestHide()
Thisworkbook.Worksheets("Sheet1").Rows("5:5").Hidden=True
Thisworkbook.Worksheets("Sheet2").Rows("5:5").Hidden=True
End Sub

This code will hide Row 5 of the respective sheets only when that sheet
is active. For a non-active sheet, the following error is displayed:
Run-time error '1004':
Unable to set the Hidden property of the Range class

Is this a known error? If so, does anyone have a more elegant
workaround then simply activating each sheet for which you would like
to manipulate with VBA code?

Thanks in advance,
Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top