Password protection with grouping causes error 1004

M

michelr

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
 

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