ACC: Sample Function to Find File AssociationsLast reviewed: June 8, 1997Article ID: Q109931 |
The information in this article applies to:
SUMMARYAdvanced: 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 INFORMATIONThe 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 FunctionTo 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.EXEif the MYDB.MDB file was associated with the MSACCESS.EXE executable file located in the ACCESS.100 directory on the D drive.
REFERENCESMicrosoft Windows Software Development Kit "Programmer's Reference, Volume 2: Functions," Version 3.1, pages 303-305 |
Keywords : kbprg PgmApi
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |