Jürgen Welz
jwelz at hotmail.com
Sun Dec 4 14:49:57 CST 2005
Marty: ShellEx returns a 2 long when it fails and my wrapper returns 'File Not Found' as I trap that return value. Windows Explorer also pops 'File not found' whenever the file fails to open when it is double clicked there. Your sample declares show both: Private Const SE_ERR_FNF = 2 and Private Const ERROR_FILE_NOT_FOUND = 2& which are of course duplicates, the second of which uses an implicit type declaration. I've also seen declares mixing hex implicit with explict: Private Const WS_EX_DLGMODALFRAME As Long = &H1& My preference these days is to explicity type the constant, skip the implicit declares and use the hex value. I almost never use an Alias in an API declare though for some inexplicable reason, I've used it for ShellExecute adding the 'A' as in the subject of this thread. I am quite confident that the file not found return is not spurious and pertains to a file that stores information about all opened/created .Pee files. IT haven't managed to get the ancilliary application running in the month since the upgrade but I think I've managed to convince powers that be that this is not an Access problem and have lit a fire under the appropriate butts. Dan: I am familiar with hyperlinking files on the server as I use this method in a monthly Excel invoicing summary sheet that stores details of invoices and includes a link to each Word doc invoice. In that case I create an acutal hyperlink in the Excel sheet as I need only display the file name and can store the full name and path in the properites. I've never tried placing hyperlinks in a list box though I guess I could just use the FollowHyperlink on the string constructed from the path and file name in the list, which is exactly what I pass to ShellExecute. Ciao Jürgen Welz Edmonton, Alberta jwelz at hotmail.com >From: MartyConnelly <martyconnelly at shaw.ca> > >I don't know if this will help, but here are the general errors from >shellexecute >There are some odd things that happen depending on folder options chosen >under NTFS >File handles are held open behind the scenes by the OS for some period >of time or maybe cached. >For example if you create a tree of folders and files via code and then >proceed to delete them >you sometimes cannot delete the highest root directory created without a >reboot. > >'http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shellexecute.asp > >'API STUFF >==================================================================== >Private 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 >Private Const SW_SHOWNORMAL = 1 >Private Const ERROR_FILE_NOT_FOUND = 2& >Private Const ERROR_PATH_NOT_FOUND = 3& >Private Const ERROR_BAD_FORMAT = 11& >Private Const SE_ERR_ACCESSDENIED = 5 >Private Const SE_ERR_ASSOCINCOMPLETE = 27 >Private Const SE_ERR_DDEBUSY = 30 >Private Const SE_ERR_DDEFAIL = 29 >Private Const SE_ERR_DDETIMEOUT = 28 >Private Const SE_ERR_DLLNOTFOUND = 32 >Private Const SE_ERR_FNF = 2 >Private Const SE_ERR_NOASSOC = 31 >Private Const SE_ERR_OOM = 8 >Private Const SE_ERR_PNF = 3 >Private Const SE_ERR_SHARE = 26 > >'strProgram is the name of a program to run, or a file to open >'EX: calc.exe or c:\test.doc or http:\\www.microsoft.com >Public Sub RunProgram(strProgram As String) > Dim lRet As Long ' Get the return value > > ' Execute the API call > lRet = ShellExecute(vbNull, "", strProgram, "", "", SW_SHOWNORMAL) > > ' If ShellExecute works it will return a number greate than 32 > ' Otherwise call our ReportError function to see what went wrong > If lRet <= 32 Then > ReportShellExecuteError (lRet) > End If >End Sub > >Private Sub ReportShellExecuteError(lErrNum As Long) > Dim strErr As String > Select Case lErrNum > Case ERROR_FILE_NOT_FOUND > strErr = "The specified file was not found." > Case ERROR_PATH_NOT_FOUND > strErr = "The specified path was not found." > Case ERROR_BAD_FORMAT > strErr = "The .exe file is invalid (non-Win32® .exe or error >in .exe image)." > Case SE_ERR_ACCESSDENIED > strErr = "The operating system denied access to the >specified file. " > Case SE_ERR_ASSOCINCOMPLETE > strErr = "The file name association is incomplete or invalid." > Case SE_ERR_DDEBUSY > strErr = "The DDE transaction could not be completed because >other DDE transactions were being processed." > Case SE_ERR_DDEFAIL > strErr = "The DDE transaction failed." > Case SE_ERR_DDETIMEOUT > strErr = "The DDE transaction could not be completed because >the request timed out." > Case SE_ERR_DLLNOTFOUND > strErr = "The specified dynamic-link library was not found. " > Case SE_ERR_FNF > strErr = "The specified file was not found. " > Case SE_ERR_NOASSOC > strErr = "There is no application associated with the given >file name extension. This error will also be returned if you attempt to > >print a file that is not printable." > Case SE_ERR_OOM > strErr = "There was not enough memory to complete the >operation." > Case SE_ERR_PNF > strErr = "The specified path was not found." > Case SE_ERR_SHARE > strErr = "A sharing violation occurred." > End Select > > MsgBox strErr, vbExclamation, "Error running program" >End Sub > > >Dan Waters wrote: > > >Jurgen, > > > >If you're still having problems, can you open the file from your screen > >using a hyperlink? I've always had good luck with this method. If you >have > >the path to the file, that's all you need to get started. > > > >Dan Waters