I haven't checked, but should it be:

If ActiveWorkbook.HasPassword = True Then
instead?