Results 1 to 6 of 6

Thread: Shell

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Posts
    6

    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??

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Use the ShellExecute() API
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    VB Code:
    1. [color=green] ' Place this right at the top of the form.[/color]
    2. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    3. (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
    4. ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    5.  
    6. [color=green] ' Insert one of these variables to the end of the statement below[/color]
    7. Private Const SW_SHOWNORMAL As Long = 1
    8. Private Const SW_MINIMIZE As Long = 6
    9. Private Const SW_MAXIMIZE As Long = 3
    10.  
    11.  
    12. Private Sub Form_Load()
    13.     Dim strYourFile As String
    14.     strYourFile = "C:\Path\File.pdf"
    15.    
    16.     ShellExecute Me.hwnd, vbNullString, strYourFile, vbNullString, "C:\", SW_SHOWNORMAL
    17. End Sub
    Last edited by alex_read; Aug 19th, 2002 at 04:46 AM.

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    *cough* alex, use vbCode, not Code *cough*
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  5. #5
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    dunno what you're on about, I did use it above - take a look

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  6. #6
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    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
  •  



Click Here to Expand Forum to Full Width