Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Opening the associated application

Posted on 2000-04-09
4
Medium Priority
?
196 Views
Last Modified: 2010-05-02
I have an application which uses a listview control to display icons that have associated Word documents with them and others that have TIFF images associated with them....(ex.  icon#1 = c:\windows\temp\doc1.doc icon#2 = c:\windows\temp\image1.tif).  I would like for the user to be able to double click the icon and the document or image to open in the associated application designated in the File Types list.  Any help would be appreciated...
0
Comment
Question by:scooterhead
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 32

Expert Comment

by:Erick37
ID: 2698847
"HOWTO: Use ShellExecute to Launch Associated File"

http://support.microsoft.com/support/kb/articles/Q170/9/18.asp
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2698967
Try This.. <smile>

Syntax:

booReturn = xShellByExtension(strFileName)


<----- Code Begin ----->

Option Explicit

Private Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA" _
  (ByVal lpFile As String, _
  ByVal lpDirectory As String, _
  ByVal lpResult As String) _
  As Long

Public Function xShellByExtension _
(ByVal strFileName As String) _
As Boolean

  Dim strProgram As String
  Dim lngReturn As Long
 
  ' Get Program PathName
  strProgram = Space(255)
  lngReturn = FindExecutable(strFileName, "", strProgram)
  If lngReturn < 32 _
  Then
    MsgBox (strFileName & " FILE NOT FOUND")
    Exit Function
  End If
  strProgram = Left$(strProgram, InStr(1, strProgram, Chr(0)) - 1)
 
  ' Execute Program with FileName as Parameter 1
  Dim StrCommand As String
  StrCommand = """ & strProgram & """ _
     & """ & strFileName & """
  lngReturn = Shell(strCommand, vbNormalFocus)
  If lngReturn > 0 _
  Then
    xShellByExtension = True 'Successful
  Else
    MsgBox (strCommand & vbCrLf & " PROGRAM NOT FOUND")
    xShellByExtension = False 'UNSUCCESSFUL
  End If
 
End Function

<----- Code End ----->
0
 
LVL 10

Accepted Solution

by:
caraf_g earned 400 total points
ID: 2699384
Here you go:

http://homepage.eircom.net/~carafa/VBSamples/VBAll/shellexecute.zip

All the hard work done for ya...
0
 

Author Comment

by:scooterhead
ID: 2837194
Thank you
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question