ShellExecute

S

Stwange

Does anyone know where I can find a detailed error code list for the
shellexecute function? Most of the sites I've found either use constants with
no conversion to the number, or only go up to around 22. I keep getting error
code 41 when I try to open a text file, any ideas?

Thank-you in advance.
 
S

Stwange

Thanks for the response. I'm using it as follows:
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
Long) As Long

and:

Public Function ShellExec(ByVal strFile As String)
Dim lngErr As Long
lngErr = ShellExecute(0, "OPEN", strFile, "", "", 0)
End Function

I have stepped through the procedure that calls it, and it passes the string
to the ShellExec function, and this string matches the file path exactly.
However, to make sure, I deleted the file it was trying to open, and I got a
different error message (so I presumed it was at least locating the file). I
then replaced the fileName.txt with a fileName.doc, and this opened fine,
which leads me to believe it has something to do with plain text files. Any
ideas?

Thank-you.
 
S

Stwange

That code use a vbNullString where I used an "OPEN", and hWndAccessApp where
I used a 0. I replaced those two and everything works fine.

Thanks for the help.
 
A

Arvin Meyer [MVP]

Checking the length of a variable with vbNullString is usefull because it
checks both Null and empty string. I always use:

If Len(myVar & vbNullString) > 0 Then

because it never fails.
 

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