| 
	       		
 (Q)    How can I find out the complete path to an executable? 
(A)    Pass the filename (not the exe file, but the document file) and
its location to this function. 
Const cMAX_PATH = 260
Const ERROR_NOASSOC = 31
Const ERROR_FILE_NOT_FOUND = 2&
Const ERROR_PATH_NOT_FOUND = 3&
Const ERROR_BAD_FORMAT = 11&
Const ERROR_OUT_OF_MEM = 0
Private Declare Function apiFindExecutable Lib "shell32.dll" _
    Alias "FindExecutableA" _
    (ByVal lpFile As String, _
    ByVal lpDirectory As String, _
    ByVal lpResult As String) _
    As Long
    
Function fFindEXE(stFile As String, _
                    stDir As String) _
                    As String
Dim lpResult As String
Dim lngRet As Long
    lpResult = Space(cMAX_PATH)
    lngRet = apiFindExecutable(stFile, stDir, lpResult)
    
    If lngRet > 32 Then
        fFindEXE = lpResult
    Else
        Select Case lngRet:
            Case ERROR_NOASSOC: fFindEXE = "Error: No Association"
            Case ERROR_FILE_NOT_FOUND: fFindEXE = "Error: File Not Found"
            Case ERROR_PATH_NOT_FOUND: fFindEXE = "Error: Path Not Found"
            Case ERROR_BAD_FORMAT:  fFindEXE = "Error: Bad File Format"
            Case ERROR_OUT_OF_MEM:  fFindEXE = "Error: Out of Memory"
        End Select
    End If
End Function
        		 |