Getting "Error 5 Invalid procedure call or argument" message

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm running the following code and get the subject message. I've enabled the
Microsoft Office 11.0 Library.

Any ideas?

' Note: This sub requires the Microsoft Office 11.0 Library
' as a Reference.

' This sub activates the Macro -> Security submenu to open
' the Macro Security dialog window for the user who is using
' the runtime version of Access '03 instead of the retail version,
' which may need to have the default security level changed in
' order to run the code in the modules.
'==============================================

Public Function openSecurityDialog()

On Error GoTo ErrHandler

Dim CmdBar As CommandBar
Dim CmdBarPopup As CommandBarPopup

Set CmdBar = Application.CommandBars("Menu Bar")
Set CmdBarPopup = CmdBar.Controls("Tools")
Set CmdBarPopup = CmdBarPopup.Controls("Macro")
CmdBarPopup.Controls("Security...").Execute

CleanUp:

Set CmdBarPopup = Nothing
Set CmdBar = Nothing

Exit Function

ErrHandler:

MsgBox "Error in openSecurityDialog( )" & vbCrLf & _
"in SecurityFunctions module." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear
GoTo CleanUp

End Function ' openSecurityDialog( )
 
Sorry: no idea. I copied your code into a new module in Access 2003, set the
reference to Office 11.0 and it worked fine for me.
 
Just realized that the system that I am currently on is running Access 2002.
This evening I will try it on a system running Access 2003. Hopefully, will
work fine. thanks for replying.
 
Back
Top