|
-
May 16th, 2000, 05:31 PM
#1
Thread Starter
Junior Member
ShellExecute - Dbclick() in a ListBox
Hi
i´m traing to open a file by dbclicking in listbox but....nothing
Here´s the code i used
[code]
Public 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
Public Const SW_SHOWNORMAL = 1
Public Sub Open_file_Excel()
Dim OK As Long
OK = ShellExecute(0&, vbNullString, "Excel", vbNullString, "c:\", SW_SHOWNORMAL)
End Sub
[code]
If i dbclick in a file it opens the excel but not the file...so there´s some parameters that open any file??
Thanks
-
May 16th, 2000, 09:35 PM
#2
Addicted Member
Hi,
if what you are trying to do is start Excel and load a file into it then use the Shell FUNCTION like this :
Shell "Path to the exe" & " " & "Path to the file", vbMaximizedFocus
Should give you something like :
Shell "C:\Excel.exe MyDoc.xls", vbMaximizedFocus
NOTE : ALL of the paths must be in short path format so use the API call GetShortPathName...
Hope thats what you wanted...
-
May 17th, 2000, 02:04 AM
#3
Assuming you use a filelistbox for this, this should work.
Code:
Option Explicit
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_SHOWNORMAL = 1
Private Sub File1_DblClick()
Dim retVal As Long
Dim Path As String
Path = File1.Path
If Right(Path, 1) <> "\" Then Path = Path & "\"
retVal = ShellExecute(Me.hwnd, "Open", Path & File1.FileName, vbNullString, Path, SW_SHOWNORMAL)
End Sub
-
May 17th, 2000, 05:49 PM
#4
Thread Starter
Junior Member
Thanks Booth
Originally posted by Frans C
Assuming you use a filelistbox for this, this should work.
Code:
Option Explicit
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_SHOWNORMAL = 1
Private Sub File1_DblClick()
Dim retVal As Long
Dim Path As String
Path = File1.Path
If Right(Path, 1) <> "\" Then Path = Path & "\"
retVal = ShellExecute(Me.hwnd, "Open", Path & File1.FileName, vbNullString, Path, SW_SHOWNORMAL)
End Sub
It works !!! Thanks Frans C and Vince
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|