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

See also:
Automating Database Compaction (every 5 times)
Automating Multiple Applications
Automating Access (Reports)
Automating Internet Explorer from Excel
Outlook Automation from within Excel
Powerpoint Automation (complex!) from within Excel
Word Automation from Excel
Automating Outlook (send email via code)
Code (via Automation) to Import Tab-Delimited File into Excel
Excel chart creation through Automation
Outlook Automation
Automation of Word (getting or starting Word)



Note to Webmaster