Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default 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" a écrit dans le message de news:
...
How can I use vba to determine what the associated image viewing program
is ?

e.g. AcdSee, Microsoft Picture Viewer etc

Regards & TIA



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Help with using vba to determine file associations

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

"Michel Pierron" wrote in message
...
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" a écrit dans le message de news:
...
How can I use vba to determine what the associated image viewing program
is ?

e.g. AcdSee, Microsoft Picture Viewer etc

Regards & TIA





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel XP and Excel 2007 file associations Palpha32 Excel Discussion (Misc queries) 0 June 18th 09 06:51 AM
Problem changing file associations in Excel 2007 Jake Excel Discussion (Misc queries) 2 February 28th 07 12:40 AM
Opening and file associations for Excel Star Excel Discussion (Misc queries) 1 October 6th 05 01:55 PM
VBA code to itemize range names and associations? Larry A[_3_] Excel Programming 13 July 2nd 05 12:42 PM
Excel hyperlink file associations - GIF joelet Excel Programming 1 September 28th 03 07:02 AM


All times are GMT +1. The time now is 06:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"