Home All Groups Group Topic Archive Search About
Author
12 Nov 2007 4:50 PM
H. Martins
Hi.

I have the following code:

Option Compare Database

    Public Declare Function ShellExecute Lib "Shell32.dll" Alias
"ShellExecuteA" _
    (ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Integer) As Long


Private Sub Command86_Click()
    r = ShellExecute(0, "open", "C:\Windows\System32\Notepad.exe", "",
"C:\", 1)
End Sub


When I click the button, I get the following error message:

"The expression On Open you entered as the event property settings
produced the following error: constants, fixed-lenght strings, arrays,
user defines types and Declare statments are not allowed as Public
members of object modules"

Can I have some help, please?

Thanks
H. Martins

Author
13 Nov 2007 4:49 PM
Phill W.
H. Martins wrote:

> Public Declare Function ShellExecute Lib "Shell32.dll" . . .

> Private Sub Command86_Click()
>     r = ShellExecute(0, "open", "C:\Windows\System32\Notepad.exe", "",
> "C:\", 1)
> End Sub

> "The expression On Open you entered as the event property settings
> produced the following error: constants, fixed-lenght strings, arrays,
> user defines types and Declare statments are not allowed as Public
> members of object modules"

The last part is the important one ...

"... Declare statements are not allowed as Public members ..."

Make the "Declare Function" Private and you should be OK.

    Private Declare Function ShellExecute Lib "Shell32.dll" . . .

HTH,
    Phill  W.