Open a PDF file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • shadowsoulja
    New Member
    • Nov 2006
    • 9

    Open a PDF file

    Okay, i dislike using VB but for a certain assignment i must.

    I want to have a button open a pdf file, it doesnt need to be in visual basic, i wud prefer it was clicked and then it loaded up in Acrobat.

    I have the address of where the file is... and i know that obviously has something to do with it.

    slap me if its that easy....


    Leon
  • Tophurious
    New Member
    • May 2007
    • 13

    #2
    well you can always use shell commands to open up the file (same commands as say the command window) or you can CreateObject("P DF.PdfCtrl.5") (i think thats right) but the latter will view within your vb program. I think if you just want to open adobe to view a shell command would be easiest

    Comment

    • SammyB
      Recognized Expert Contributor
      • Mar 2007
      • 807

      #3
      In .Net, it looks like:
      Code:
      Dim pRun As System.Diagnostics.Process = New System.Diagnostics.Process
      pRun.StartInfo.FileName = "C:\SomePath\TheFile.pdf"
      pRun.StartInfo.UseShellExecute = True
      pRun.Start()

      Comment

      • shadowsoulja
        New Member
        • Nov 2006
        • 9

        #4
        Im using VB6... not sure if that helps.

        im not sure on any of this shell stuff.... you might have to babyfeed it to me until i have something i recognise.

        Sorry

        Leon

        Comment

        • Tophurious
          New Member
          • May 2007
          • 13

          #5
          easy enough

          basically its

          Shell(pathname, window style)

          pathname as string

          window style i would recommend either
          vbMaximizedFocu s -maximize it and focus
          vbNormalFocus -open normal and focus

          Comment

          • SammyB
            Recognized Expert Contributor
            • Mar 2007
            • 807

            #6
            Originally posted by shadowsoulja
            Im using VB6... not sure if that helps.

            im not sure on any of this shell stuff.... you might have to babyfeed it to me until i have something i recognise.

            Sorry

            Leon
            No problem, it's just a one liner, something like this:
            Shell "C:\Program Files\Adobe\Acr obat 7.0\Reader\Acro Rd32 C:\Documents and Settings\cheryl test\My Documents\ArcMa p.pdf", vbNormalFocus

            IE
            Shell "ReaderPath DocFileSpec", WindowState

            Comment

            • shadowsoulja
              New Member
              • Nov 2006
              • 9

              #7
              Thanks for the help guys, much apprieciated

              Comment

              • Shayne82609
                New Member
                • Nov 2008
                • 3

                #8
                Originally posted by SammyB
                No problem, it's just a one liner, something like this:
                Shell "C:\Program Files\Adobe\Acr obat 7.0\Reader\Acro Rd32 C:\Documents and Settings\cheryl test\My Documents\ArcMa p.pdf", vbNormalFocus

                IE
                Shell "ReaderPath DocFileSpec", WindowState

                Ok, first please forgive me for being a noobie. I am working on a VB6 program to be included in a business CD. The goal is to burn it and the related .pdf files to a CD to be able to distribute to vendors and clients. Basically a autostart CD menu. VB6 is what I have to work with, not by choice.

                The code lines above will open a specific version of A.R. if installed into a specific place. I need one that will open the AcroRd32 file in much more generic fashion. Is there a way to do this, so that no matter what version they have it will open the .pdf file with the "Windows default"?

                This is what I have so far. It works if and ONLY if the drive letters are correct.

                Private Sub Command1_Click( )
                Dim RetVal
                RetVal = Shell("C:\Progr am Files\Adobe\Rea der 9.0\Reader\acro rd32 I:\brochure.pdf ")
                End Sub

                If the drive letters are not right, it obviously wont work, hence the problem.


                Thanx.
                Last edited by Shayne82609; Nov 18 '08, 08:33 PM. Reason: additional comments

                Comment

                • rpicilli
                  New Member
                  • Aug 2008
                  • 77

                  #9
                  Hi there

                  If you're using new version of VB you can type the following


                  Process.Start(" c:\mypdffile.pd f")

                  More easy then that just if you double click over the file...

                  Comment

                  • Timothy Howell

                    #10
                    I know that your project isn't being worked on any more. But the script to get the drive letter in VB looks like this:
                    Code:
                    Public Function OpticalDrive()
                            Dim CDRom As String = ""
                    
                            For Each drive_info As DriveInfo In DriveInfo.GetDrives()
                                If (drive_info.DriveType() = DriveType.CDRom) Then
                                    If (drive_info.IsReady = True) Then
                                        CDRom = drive_info.Name
                                    End If
                                End If
                            Next drive_info
                    
                            Return CDRom
                        End Function

                    Comment

                    Working...