How can I use vba to determine what the associated image viewing program is
?
e.g. AcdSee, Microsoft Picture Viewer etc
Regards & TIA
How can I use vba to determine what the associated image viewing program is
?
e.g. AcdSee, Microsoft Picture Viewer etc
Regards & TIA
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
>
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
>>
>
>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks