ShellExecute error

H

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
 
R

rowe_newsgroups

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

I highly suspect you are in the wrong newsgroup. The Access newsgroup
is at comp.databases.ms-access

Thanks,

Seth Rowe
 
P

Phill W.

H. Martins said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top