Kamis, 24 Oktober 2013

RE: [MS_AccessPros] RE: How to avoid opening a password-protected mdb

 

Try passing it a blank password so that it knows the password has already been attempted to be supplied by your code.

 

app.OpenCurrentDatabase strPath,, ""

 

John Viescas, Author

Microsoft Access 2010 Inside Out

Microsoft Access 2007 Inside Out

Microsoft Access 2003 Inside Out

Building Microsoft Access Applications

SQL Queries for Mere Mortals

http://www.viescas.com/

(Paris, France)

 

 

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of giorgio_rovelli
Sent: Thursday, October 24, 2013 11:00 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] RE: How to avoid opening a password-protected mdb

 




Thank you John, I've tried to solve it as follows:

Sub ProcessDatabase(ByVal strPath As String)
    Dim vbc As VBIDE.VBComponent
    On Error GoTo ExitHere
    app.OpenCurrentDatabase strPath
    For Each vbc In app.VBE.ActiveVBProject.VBComponents
        ProcessModule vbc.CodeModule, strPath
    Next vbc
ExitHere:
    If Err = 2467 Then
        app.CloseCurrentDatabase
        Exit Sub
    End If
    app.CloseCurrentDatabase
End Sub

 

because when the dialog box asking for the database password comes up and I click the Cancel button I get the message: "run-time error '2467': The expression you entered refers to an object that is closed or doesn't exist."

but it doesn't allow me to exit the dialog box gracefully and continue the scan with the next mdb, what can I do to achieve that?

 

Giorgio



---In ms_access_professionals@yahoogroups.com, <JohnV@...> wrote:

Giorgio-

 

If the database itself is password protected, I don't know of any way to detect that without trying to open the database and getting an error.

 

John Viescas, Author

Microsoft Access 2010 Inside Out

Microsoft Access 2007 Inside Out

Microsoft Access 2003 Inside Out

Building Microsoft Access Applications

SQL Queries for Mere Mortals

http://www.viescas.com/

(Paris, France)

 

 

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of giorgio_rovelli
Sent: Thursday, October 24, 2013 8:48 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] How to avoid opening a password-protected mdb

 



I'm looping through my pc's folders to open each mdb that I find and look for a sub in the vba modules. The problem is there are a few mdb's which have been password-protected and so I'd like to skip opening them since I don't know the password. How can I modify the following code to achieve that?

 

Sub ProcessDatabase(ByVal strPath As String)
    Dim vbc As VBIDE.VBComponent
    app.OpenCurrentDatabase strPath
    For Each vbc In app.VBE.ActiveVBProject.VBComponents
        ProcessModule vbc.CodeModule, strPath
    Next vbc
    app.CloseCurrentDatabase
End Sub






__._,_.___
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (4)
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar