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: ShellExecute question - microsoft.public.scripting.vbscript ...I have a script that uses the ShellExecute function to run wscript.exe in Windows 7 as an elevated user (with the "runas" verb). When it runs, a UAC... on-screen keyboard issue on Win7 64-bit - microsoft.public.windows ...I am running my 32 bit application on a Win7 64-bit machine and when my code tries to open the on-screen keyboard via the ShellExecute command, e.g.... How to start excel in "safe mode" programmatically ...Thanks Abhishek "Homey" wrote: > maybe see this work ok > > Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _ > (ByVal hRegEdit As Long ... Word 2007 (on Vista) crashes when using CreateObject in VBA ...Can anyone help with this? I think it may be the config of my laptop, but don't know what specifically. I'm trying to open an app in VBA using Cre... Run-time error '509' while printing a word document ...... Word select >> Tools=>Protect document, with editing restictions selected) >> >> Now the document is printed to the default windows printrer using >> ShellExecute ... Microsoft Access 2003 Hyperlinks - microsoft.public.access ...Instead of using a hyperlink, try using ShellExecute to start an app with it's associated program. Not only should it be faster, but you can store a simple path as a ... Opening XFDL form using VBA - microsoft.public.access ...You can invoke such command using VBA's Shell function or the Windows API's ShellExecute function. You can know if your app supports this if you can double-click a ... Access hyperlinks ignore file associations - microsoft.public ...If ShellExecute(Access.hWndAccessApp, sAction, sFileName, vbNullString, "", SW_SHOWNORMAL) < 33 Then DoCmd.Beep MsgBox "File not found." Hyperlink opens in internet explorer and not default - microsoft ...The Hyperlink protocol defaults to opening in IE. I would change the hyperlink to a text field and remove all references to the protocol. Then use ShellExecute to ... Add user to local security group in Win7 - microsoft.public ...The ShellExecute post is more of a workaround as I would still prefer a way to make it work without getting UAC involved. However, if the ShellExecute is the only way ... ShellExecute function - Microsoft Corporation: Software ...There are certainly instances where ShellExecute does not use one of these types of Shell extension and those instances would not require COM to be ... ShellExecuteEx function - Microsoft Corporation: Software ...If you are afraid ShellExecute(Ex) might misidentify the file type, because the path might be ambiguous or if you use a non-standard type system, you can force ... WD2000: How to Call the ShellExecute Windows API FunctionYou can call the ShellExecute() Windows API function from a Visual Basic for Applications macro to start another program under Microsoft Windows. Use ... Use ShellExecute to launch the default Web browserThis article provides general information about how to register the default Web browser and then how to start the default Web browser with the application ... How To Use ShellExecute to Launch Associated File (32-bit)You can use the Windows API ShellExecute() function to start the application associated with a given document extension without knowing the name of the ... 7/25/2012 12:29:06 PM
|