ShellExecute

  • Follow


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.
0
Reply Utf 8/20/2007 11:50:02 AM

According to the documentation at 
http://msdn2.microsoft.com/en-us/library/ms647732.aspx, the function 
"Returns a value greater than 32 if successful, or an error value that is 
less than or equal to 32 otherwise."

In other words, 41 should indicate that there is no error.

How are you trying to use the function?

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Stwange" <Stwange@discussions.microsoft.com> wrote in message 
news:3C09DD04-9299-451C-BB7B-E7E37431AD2F@microsoft.com...
> 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. 


0
Reply Douglas 8/20/2007 12:18:25 PM


Take a look at http://www.mvps.org/access/api/api0018.htm at "The Access 
Web".

That code works fine for me with existing text files.

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Stwange" <Stwange@discussions.microsoft.com> wrote in message 
news:C87E0C6D-4819-4222-9F8E-827A68F5D0C2@microsoft.com...
> 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. 


0
Reply Douglas 8/20/2007 12:42:01 PM

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.

"Douglas J. Steele" wrote:

> Take a look at http://www.mvps.org/access/api/api0018.htm at "The Access 
> Web".
> 
> That code works fine for me with existing text files.
> 
> -- 
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
> 
> 
> "Stwange" <Stwange@discussions.microsoft.com> wrote in message 
> news:C87E0C6D-4819-4222-9F8E-827A68F5D0C2@microsoft.com...
> > 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. 
> 
> 
> 
0
Reply Utf 8/20/2007 1:08:00 PM

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.
-- 
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

"Stwange" <Stwange@discussions.microsoft.com> wrote in message 
news:23F4A127-40E9-489B-ABEA-E3EBEDAC2C7C@microsoft.com...
> 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.
>
> "Douglas J. Steele" wrote:
>
>> Take a look at http://www.mvps.org/access/api/api0018.htm at "The Access
>> Web".
>>
>> That code works fine for me with existing text files.
>>
>> -- 
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>>
>> "Stwange" <Stwange@discussions.microsoft.com> wrote in message
>> news:C87E0C6D-4819-4222-9F8E-827A68F5D0C2@microsoft.com...
>> > 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.
>>
>>
>> 


0
Reply Arvin 8/20/2007 2:02:35 PM

4 Replies
400 Views

(page loaded in 0.106 seconds)

Similiar Articles:
















7/25/2012 12:29:06 PM


Reply: