ACC: Sample Function to Find File AssociationsID: Q109931
|
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().
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
D:\ACCESS.100\MSACCESS.EXE
Microsoft Windows Software Development Kit "Programmer's Reference, Volume 2: Functions," Version 3.1, pages 303-305
Keywords : kbprg
Version : 1.0 1.1 2.0
Platform : WINDOWS
Issue type : kbinfo
Last Reviewed: April 1, 1999