Results 1 to 3 of 3

Thread: Opening files

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Location
    London, United Kingdom
    Posts
    14

    Post

    I need to open a file from my .exe file but it is application specific and I would like my exe file to open the application first and then open the file within the application. (It's a .pdf graphics file that needs to be opened in Acrobat Reader.)

    Can anyone help?

    Cheers!

  2. #2
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    There are two methods you can use:
    Code:
    Private Sub Command1_Click()
        Shell Chr(34) & "C:\Program Files\Acroread\Acrord32.exe" & Chr(34) & " SomePDF.pdf", vbNormalFocus
    End sub
    Where Acrord32.exe is the Acrobat Reader EXE and SomePDF.pdf is the File and Path of the PDF you want to launch.

    Or, more intuitively..
    Code:
    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 Command1_Click()
        ShellExecute 0&, "OPEN", "SomePDF.pdf", "", "", 1
    End Sub
    This method doesn't require you to know the location or name of the PDF Reader, as it launches the Associated EXE.


    ------------------
    Aaron Young
    Analyst Programmer
    [email protected]
    [email protected]

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Location
    London, United Kingdom
    Posts
    14

    Post

    Thanks.

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