ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel 2003 Userinterfaceonly Password Protection Problem (https://www.excelbanter.com/excel-programming/331251-excel-2003-userinterfaceonly-password-protection-problem.html)

[email protected]

Excel 2003 Userinterfaceonly Password Protection Problem
 
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").Hidd en=True
Thisworkbook.Worksheets("Sheet2").Rows("5:5").Hidd en=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


Ron de Bruin

Excel 2003 Userinterfaceonly Password Protection Problem
 
Hi

I have test it on a 2003 machine and it is working for me


--
Regards Ron de Bruin
http://www.rondebruin.nl


wrote in message oups.com...
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").Hidd en=True
Thisworkbook.Worksheets("Sheet2").Rows("5:5").Hidd en=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





All times are GMT +1. The time now is 10:36 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com