ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Password protection with grouping causes error 1004 (https://www.excelbanter.com/excel-programming/361297-password-protection-grouping-causes-error-1004-a.html)

michelr

Password protection with grouping causes error 1004
 

Hi,

I have the followiing macro in ThisWorkbook (suggested in anothe
topic) to allow grouping and ungrouping in a password protected file.

Sub WorkBook_Open()
Application.ScreenUpdating = False
Dim n As Single
For n = 1 To Sheets.Count
With Sheets(n)
.Protect Password:="test", userinterfaceonly:=True
.EnableOutlining = True
.EnableAutoFilter = True
End With
Next n
Application.ScreenUpdating = True
End Sub

When i apply it to an excel 2000 file it works perfectly. But when
want to open the file in excel 2003 it gives an error:

-Run-time error 1004: The password you supplied is not correct. Verif
that the caps lock is off etc.etc.-

This starts with the worksheets that use grouping. The other sheet
before that sheet (with no grouping) are all password protected wit
the correct password.

Can anybody help? I'm new to macro's...

Thanx!

Miche

--
michel
-----------------------------------------------------------------------
michelr's Profile: http://www.excelforum.com/member.php...fo&userid=3437
View this thread: http://www.excelforum.com/showthread.php?threadid=54148



All times are GMT +1. The time now is 04:44 PM.

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