Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I supress the message? 1

Status
Not open for further replies.

Gavona

Technical User
Aug 27, 2002
1,771
GB
When this code gets to the Workbooks.open line I get runtime 1004 "The password you supplied is not correct....."
And if I test in the immediate window DisplayAlerts has been reset to True.
I must be making a silly error but can't work out what :(

Code:
    For Each c In rPasswordList
        On Error GoTo TryTheNextOne
        Application.DisplayAlerts = False
        Workbooks.Open strWbkfullname, Password:=c.Value
        On Error GoTo 0

    Exit Sub

TryTheNextOne:
    Err.Clear
    Next c

Gavin
 
If the password is wrong, you get runtime error, so DisplayAlerts is useless for this purpose. You need Resume:

[pre]For Each c In rPasswordList
On Error GoTo TryTheNextOne
Application.DisplayAlerts = False
Workbooks.Open strWbkfullname, Password:=c.Value

Exit Sub

TryTheNextOne:
Err.Clear
Resume ResumeHere
ResumeHere:
Next c[/pre]

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top