Option Explicit
Option Private Module

' ---------------------------------------------------------
 ' Funktion StandardAnwendung
 ' Eingestellt von: Andre Schau
 ' Datum: 5. Juno 2011
 ' Kommentar: Funktion zur Ermittlung der
 ' Standardanwendung eines Dateitypes
 ' Parameter: strPathFile
 ' Rückgabe: Pfad und Name der Anwendung
 ' siehe API-Argumente
 ' weitere benoetigte Programme und Funktionen
 ' API-Funktion: FindExecutable
 ' Aufruf: Beispiel siehe Sub callStandardAnwendung()
 
' Deklarierung der API-Funktion
Declare Function FindExecutable Lib "shell32.dll" _
  Alias "FindExecutableA" (ByVal lpFile As String, _
  ByVal lpDirectory As String, _
  ByVal lpResult As StringAs Long

Sub callStandardAnwendung()
MsgBox Application.WorksheetFunction.Clean(StandardAnwendung("D:\Test\test.txt"))
End Sub

Function StandardAnwendung(ByVal strPathFile As StringAs String
'Variablendeklarationen
'Long
  Const loBUFF As Long = 256
'String
  Dim strPath As String * loBUFF
'API-Argumente: Dateiname inclusive LW und Pfad
'API-Aufruf
  FindExecutable strPathFile, vbNullString, strPath
'Rueckgabewert uebernehmen, Sonderzeichen entfernen
  StandardAnwendung = Application.WorksheetFunction.Clean(strPath)
End Function