ShellExecute in VB2005

G

Guest

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.
 
H

Herfried K. Wagner [MVP]

Jedi10180 said:
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'.
 
O

Oenone

Jedi10180 said:
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()
///
 
G

Guest

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.
 
G

Guest

why doesn't cmd.exe with arguments /c copy c:\file.txt d:\directory work with
the process start?
 
G

Guest

Jedi10180,

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

Kerry Moorman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top