468,791 Members | 1,799 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,791 developers. It's quick & easy.

ShellExecute in VB2005

Does ShellExecute work in VB2005? I am trying to open a pdf with a button - I
get no errors, but nothing is happening. Here is my code:
Option Explicit On

Public Class frmPROTest
Const SW_SHOWNORMAL = 1
Dim hwnd

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 Sub PDF_Click()

Call ShellExecute(Me.hwnd, "open", "S:\Users\JJolly\PRO
CD\pdf\english\ESY Book.pdf", "", 0, SW_SHOWNORMAL)

End Sub

End Class

Thanks for any help.
Jan 17 '06 #1
5 8478
"Jedi10180" <Je*******@discussions.microsoft.com> schrieb:
Does ShellExecute work in VB2005? I am trying to open a pdf with a
button - I
get no errors, but nothing is happening. Here is my code:
Option Explicit On

Public Class frmPROTest
Const SW_SHOWNORMAL = 1
Dim hwnd

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


Your declarations are wrong. Instead of fixing them, I suggest to use
'System.Diagnostics.Process.Start' instead of 'ShellExecute'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 17 '06 #2
Jedi10180 wrote:
Does ShellExecute work in VB2005? I am trying to open a pdf with a
button - I get no errors, but nothing is happening.


Have you considered the following method using the .NET framework?

\\\
Dim proc As New Process

With proc.StartInfo
.FileName = "S:\Users\JJolly\PRO CD\pdf\english\ESY Book.pdf"
.UseShellExecute = True
.Verb = "open"
End With

'Launch the file
proc.Start()
///

--

(O)enone
Jan 17 '06 #3
I have also tried 'System.Diagnostics.Process.Start', but apparently my
declarations are wrong when I try it too because nothing happens at all. Can
you just give a short code snippet that would include everything I need to
open a pdf file using 'System.Diagnostics.Process.Start'?
Also, we want this program to be run directly from a CD with no installation
- how do I go about doing that?
Thanks.

"Herfried K. Wagner [MVP]" wrote:
"Jedi10180" <Je*******@discussions.microsoft.com> schrieb:
Does ShellExecute work in VB2005? I am trying to open a pdf with a
button - I
get no errors, but nothing is happening. Here is my code:
Option Explicit On

Public Class frmPROTest
Const SW_SHOWNORMAL = 1
Dim hwnd

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


Your declarations are wrong. Instead of fixing them, I suggest to use
'System.Diagnostics.Process.Start' instead of 'ShellExecute'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 17 '06 #4
why doesn't cmd.exe with arguments /c copy c:\file.txt d:\directory work with
the process start?

"Oenone" wrote:
Jedi10180 wrote:
Does ShellExecute work in VB2005? I am trying to open a pdf with a
button - I get no errors, but nothing is happening.


Have you considered the following method using the .NET framework?

\\\
Dim proc As New Process

With proc.StartInfo
.FileName = "S:\Users\JJolly\PRO CD\pdf\english\ESY Book.pdf"
.UseShellExecute = True
.Verb = "open"
End With

'Launch the file
proc.Start()
///

--

(O)enone

Jan 17 '06 #5
Jedi10180,

Programs written in a .Net language require the .Net framework to be
installed in order to execute the program.

Kerry Moorman
"Jedi10180" wrote:
Also, we want this program to be run directly from a CD with no installation
- how do I go about doing that?
Thanks.


Jan 17 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Marcel Sammut | last post: by
3 posts views Thread by Wiktor Zychla | last post: by
1 post views Thread by MCzajk | last post: by
11 posts views Thread by Le, Thanh-Nhan | last post: by
reply views Thread by the_openFace | last post: by
reply views Thread by the openBack | last post: by
reply views Thread by David | last post: by
4 posts views Thread by fdmaxey | last post: by
2 posts views Thread by John Smith | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.