|
-
Aug 19th, 2002, 04:15 AM
#1
Thread Starter
New Member
Shell
I want to open up a report in acrobat reader using VB. I dont want to add any more references or components, so I am trying to use the Shell command, but cant get it to work.
The line of code is Shell ("start c:\1.pdf"). I get the error file not found. If I try it in a command prompt it works OK e.g start c:\1.pdf. Is it possible to use the start command in shell??, if so how??
-
Aug 19th, 2002, 04:26 AM
#2
Retired VBF Adm1nistrator
Use the ShellExecute() API
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Aug 19th, 2002, 04:33 AM
#3
VB Code:
[color=green] ' Place this right at the top of the form.[/color]
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
[color=green] ' Insert one of these variables to the end of the statement below[/color]
Private Const SW_SHOWNORMAL As Long = 1
Private Const SW_MINIMIZE As Long = 6
Private Const SW_MAXIMIZE As Long = 3
Private Sub Form_Load()
Dim strYourFile As String
strYourFile = "C:\Path\File.pdf"
ShellExecute Me.hwnd, vbNullString, strYourFile, vbNullString, "C:\", SW_SHOWNORMAL
End Sub
Last edited by alex_read; Aug 19th, 2002 at 04:46 AM.
-
Aug 19th, 2002, 04:34 AM
#4
Retired VBF Adm1nistrator
*cough* alex, use vbCode, not Code *cough*
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Aug 19th, 2002, 04:47 AM
#5
dunno what you're on about, I did use it above - take a look
-
Aug 19th, 2002, 04:50 AM
#6
Retired VBF Adm1nistrator
Originally posted by alex_read
dunno what you're on about, I did use it above - take a look
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
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
|