Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Launch from FileList 2

Status
Not open for further replies.

TapeMan

Vendor
Feb 19, 2002
18
0
0
GB
I'm sure this is simple, but I can't work out how to do it!

I have an application that displays the contents of a certain directory in a FileList box. So far, so good. Typically the file list will contain .doc, .xls, vsd, .rtf, .pdf files. I want to be able to click on a file name, and have vb6 open that file with the relevant application and display the data. I intend to change the file attributes before displaying to 'Read-Only' as I do not want the file contents changing.

Is there a simple way to do this or do I need to examine the extension and launch the appropriate application?

Thanks in anticipation.
 
Code:
    Shell "RUNDLL32.EXE URL.DLL, FileProtocolHandler " & DocumentWithPath, vbNormalFocus

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
Essex Steam UK for steam enthusiasts
 
A little caution on the use of rundll32.exe. See thread222-1021403.
 
Excellent, worked a treat, many thanks (and the app is only for XP and W2K).
 
I prefer an API (from AllAPI.NET) - ShellExecute

Option Explicit
Dim x As String

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const SW_HIDE As Long = 0
Private Const SW_SHOWNORMAL As Long = 1

Private Sub Command1_Click()
x = File1.FileName
ShellExecute 0&, "OPEN", File1.Path & "\" & x, vbNullString, "C:\", SW_SHOWNORMAL
End Sub

Private Sub Form_Load()
File1.Path = "\temp\"
End Sub

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top