Article ID: 109931
Article Last Modified on 5/6/2003
APPLIES TO
- Microsoft Access 1.0 Standard Edition
- Microsoft Access 1.1 Standard Edition
- Microsoft Access 2.0 Standard Edition
This article was previously published under Q109931
SUMMARY
Advanced: Requires expert coding, interoperability, and multiuser skills.
This article demonstrates a sample Access Basic function that you can use to obtain the executable file name associated with a document file name by calling the Microsoft Windows API function FindExecutable().
MORE INFORMATION
The following sample function requires a path string parameter and a file name string parameter. The function returns the path of the associated file.
NOTE: In the following sample code, an underscore (_) is used as a line- continuation character. Remove the underscore from the end of the line when re-creating this code in Access Basic.
' *** Declarations Section *** Option Explicit Declare Function FindExecutable% Lib "Shell" (ByVal lpszFile$, _ ByVal lpszDir$, ByVal lpszResult$) Function GetAssociation (Path As String, FileName As String) Dim Result As String, X As Integer Result = Space$(256) X = FindExecutable(FileName, Path, Result) GetAssociation = Result End Function
To find the path and name of the executable file associated with a file called MYDB.MDB that is located in the root directory on the D drive you could type the following in an Immediate window:
? GetAssociation ("D:\", "MYDB.MDB")
The function would return
D:\ACCESS.100\MSACCESS.EXE
if the MYDB.MDB file was associated with the MSACCESS.EXE executable file located in the ACCESS.100 directory on the D drive.
REFERENCES
Microsoft Windows Software Development Kit "Programmer's Reference, Volume 2: Functions," Version 3.1, pages 303-305
Keywords: kbinfo kbprogramming KB109931