+ Reply to Thread
Results 1 to 3 of 3

Help with using vba to determine file associations

  1. #1
    Nice but Dim
    Guest

    Help with using vba to determine file associations

    How can I use vba to determine what the associated image viewing program is
    ?

    e.g. AcdSee, Microsoft Picture Viewer etc

    Regards & TIA



  2. #2
    Michel Pierron
    Guest

    Re: Help with using vba to determine file associations

    Hi Nice but Dim,
    Private Declare Function FindExecutable& Lib "shell32.dll" Alias _
    "FindExecutableA" (ByVal lpFile$, ByVal lpDirectory$, ByVal lpResult$)

    Private Function GetFileAssociation$(ByVal sFile$)
    GetFileAssociation = "File not found !"
    If Dir(sFile) = "" Or sFile = "" Then Exit Function
    GetFileAssociation = "No association found !"
    Dim i&, E$: E = String(260, Chr$(0))
    i = FindExecutable(sFile, vbNullString, E)
    If i > 32 Then GetFileAssociation = Left$(E, InStr(E, Chr$(0)) - 1)
    End Function

    Sub Test()
    MsgBox GetFileAssociation("C:\Iceberg.jpg"), 64
    End Sub

    Regards,
    MP

    "Nice but Dim" <[email protected]> a écrit dans le message de news:
    [email protected]...
    > How can I use vba to determine what the associated image viewing program
    > is ?
    >
    > e.g. AcdSee, Microsoft Picture Viewer etc
    >
    > Regards & TIA
    >




  3. #3
    Nice but Dim
    Guest

    Re: Help with using vba to determine file associations

    Many thanks Michel,
    You guys are amazing
    Regards
    Jim (Nice but dim)

    "Michel Pierron" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Nice but Dim,
    > Private Declare Function FindExecutable& Lib "shell32.dll" Alias _
    > "FindExecutableA" (ByVal lpFile$, ByVal lpDirectory$, ByVal lpResult$)
    >
    > Private Function GetFileAssociation$(ByVal sFile$)
    > GetFileAssociation = "File not found !"
    > If Dir(sFile) = "" Or sFile = "" Then Exit Function
    > GetFileAssociation = "No association found !"
    > Dim i&, E$: E = String(260, Chr$(0))
    > i = FindExecutable(sFile, vbNullString, E)
    > If i > 32 Then GetFileAssociation = Left$(E, InStr(E, Chr$(0)) - 1)
    > End Function
    >
    > Sub Test()
    > MsgBox GetFileAssociation("C:\Iceberg.jpg"), 64
    > End Sub
    >
    > Regards,
    > MP
    >
    > "Nice but Dim" <[email protected]> a écrit dans le message de news:
    > [email protected]...
    >> How can I use vba to determine what the associated image viewing program
    >> is ?
    >>
    >> e.g. AcdSee, Microsoft Picture Viewer etc
    >>
    >> Regards & TIA
    >>

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1