Very nice piece of code. Im having trouble receiving the file association however. I keep hitting the error trap on every type of file im attempting to open. What exactly does the 'success' variable in the code do? retassoc ends up being an empty string on each attempt. An exampple of the string im sending to LoadUserFile (FN2Load) is "o:\P1263_1.txt". This file exists and is able to be opening through explorer as is all the other files ive attemted to open.
Any help is appreciated. Thank you.
Your code unchanged:
Function retassoc(ByVal fn As String, ByVal fpath As String) As String
' retrieve the associated program that uses this file
Dim success As Long
Dim pos As Long
Dim sResult As String
sResult = Space$(MAX_PATH)
success = FindExecutable(fn, fpath, sResult)
pos = InStr(sResult, Chr$(0))
If pos Then
retassoc = Left$(sResult, pos - 1)
End If
End Function