Code to Determine the File Association (with example):
Return to List
Const MAX_PATH = 260
Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" _
(ByVal lpFile As String, ByVal lpDirectory As String, _
ByVal lpResult As String) As Long
Sub Main()
Dim lngResult As Long
Dim strBuffer As String
strBuffer = Space$(MAX_PATH)
With Dialogs(wdDialogFileOpen)
.Name = "*.*"
.Display
Dim NameVar As String
NameVar = .Name
FullNameOfDoc = CurDir & "\" & NameVar
FullNameOfDoc = ReplaceWithin(FullNameOfDoc, Chr(34), "") ' Using function _
to eliminate any quotes being included
End With
lngResult = FindExecutable(FullNameOfDoc, "", strBuffer)
If Len(strBuffer) = 0 Then
strBuffer = "Unknown"
End If
' strBuffer is the Executable associated with the file End Sub