Open pdf file with button in VB 2005

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jedi10180

    #1

    Open pdf file with button in VB 2005

    I am making a CD for the non-profit organization I work for. The CD contains
    all of the publications that we publish and will contain a GUI to access
    them. When the user clicks on a publication button in the GUI, the pdf of the
    publication needs to open in an Adobe Reader/Acrobat window. I can't figure
    out how to make this work in VB.

    I was told to try this:
    [color=blue]
    >You'd want to use ShellExecute, as shown on
    >http://vb.mvps.org/samples/hyperjmp...
    >
    > Private Declare Function ShellExecute Lib "shell32.dl l" 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
    >
    > Public Function OpenDoc(ByVal DocFile As String) As Long
    > ' Actually uses the default verb if available, and "open" otherwise
    > OpenDoc = ShellExecute(0& , vbNullString, DocFile, vbNullString,
    >vbNullString , vbNormalFocus)
    > End Function
    >
    >Pass the path/name of the desired PDF to this OpenDoc function.[/color]

    I've tried that, but now my problem is I've been messing around with
    ShellExecute for awhile and I'm having issues.
    I don't think I'm passing the path/name of the PDF to the OpenDoc function
    correctly. If I have a button named 'PDF', that calls the OpenDoc function
    and passes the path/filename to it when it's clicked, what would the function
    call look like?

    Thanks for any help.

  • Herfried K. Wagner [MVP]

    #2
    Re: Open pdf file with button in VB 2005

    "Jedi10180" <Jedi10180@disc ussions.microso ft.com> schrieb:[color=blue]
    >I am making a CD for the non-profit organization I work for. The CD
    >contains
    > all of the publications that we publish and will contain a GUI to access
    > them. When the user clicks on a publication button in the GUI, the pdf of
    > the
    > publication needs to open in an Adobe Reader/Acrobat window. I can't
    > figure
    > out how to make this work in VB.[/color]

    \\\
    System.Diagnost ics.Process.Sta rt("C:\sample.p df")
    ///

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    • Paul Bromley

      #3
      Re: Open pdf file with button in VB 2005

      In VB2003, embedding the Adobe Acrobat 7 Browser Document control in the
      project works well for me, but I have not been able to find out the
      licensing implications, of using this in a VB.NET project. The user needs to
      install Acrobat Reader 7 on their machine. Can anyone confirm if this is an
      acceptable use or not for the control??

      Code:-

      With AxPDF1
      ..Visible = True
      ..setShowToolba r((True))
      ..LoadFile("C:\ Statement.pdf")
      Cursor.Current = Cursors.Default
      ..Show()
      ..Select()
      ..SuspendLayout ()
      End With

      Best wishes

      Paul Bromley

      "Jedi10180" <Jedi10180@disc ussions.microso ft.com> wrote in message
      news:010E5C93-B77A-45E4-A634-58425585E203@mi crosoft.com...[color=blue]
      >I am making a CD for the non-profit organization I work for. The CD
      >contains
      > all of the publications that we publish and will contain a GUI to access
      > them. When the user clicks on a publication button in the GUI, the pdf of
      > the
      > publication needs to open in an Adobe Reader/Acrobat window. I can't
      > figure
      > out how to make this work in VB.
      >
      > I was told to try this:
      >[color=green]
      >>You'd want to use ShellExecute, as shown on
      >>http://vb.mvps.org/samples/hyperjmp...
      >>
      >> Private Declare Function ShellExecute Lib "shell32.dl l" Alias
      >>"ShellExecute A" (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
      >>
      >> Public Function OpenDoc(ByVal DocFile As String) As Long
      >> ' Actually uses the default verb if available, and "open" otherwise
      >> OpenDoc = ShellExecute(0& , vbNullString, DocFile, vbNullString,
      >>vbNullStrin g, vbNormalFocus)
      >> End Function
      >>
      >>Pass the path/name of the desired PDF to this OpenDoc function.[/color]
      >
      > I've tried that, but now my problem is I've been messing around with
      > ShellExecute for awhile and I'm having issues.
      > I don't think I'm passing the path/name of the PDF to the OpenDoc function
      > correctly. If I have a button named 'PDF', that calls the OpenDoc function
      > and passes the path/filename to it when it's clicked, what would the
      > function
      > call look like?
      >
      > Thanks for any help.
      >[/color]


      Comment

      • PJ on Development

        #4
        Re: Open pdf file with button in VB 2005

        Paul,

        The Acrobat Reader is a free tool, and as such can be freely
        distributed.

        Licensing implication would occur only if the software used
        technologies from the Acrobat Generator (I forgot the proper name),
        which I think it's not the case.

        All in all, it's a good thing to ship the Acrobat Reader with the
        application and install it on the user machine, warning the user of
        such behavior (Can some one spell SONY? ;-)

        It would be a good thing too to check if the user box has already the
        Acrobat Reader installed (at least the bare minimum to read the docs)
        before installing.

        Regards,

        PJ


        Comment

        • Paul Bromley

          #5
          Re: Open pdf file with button in VB 2005

          Thanks PJ

          The reason I ask is that other PDF viewer controls seem to be so expensive.
          Installing Reader 7 seems a small price to pay to use this control in your
          applications.

          Best wishes

          Paul


          "PJ on Development" <pjondevelopmen t@gmail.com> wrote in message
          news:1137023232 .127420.316900@ g49g2000cwa.goo glegroups.com.. .[color=blue]
          > Paul,
          >
          > The Acrobat Reader is a free tool, and as such can be freely
          > distributed.
          >
          > Licensing implication would occur only if the software used
          > technologies from the Acrobat Generator (I forgot the proper name),
          > which I think it's not the case.
          >
          > All in all, it's a good thing to ship the Acrobat Reader with the
          > application and install it on the user machine, warning the user of
          > such behavior (Can some one spell SONY? ;-)
          >
          > It would be a good thing too to check if the user box has already the
          > Acrobat Reader installed (at least the bare minimum to read the docs)
          > before installing.
          >
          > Regards,
          >
          > PJ
          > http://pjondevelopment.50webs.com/
          >[/color]


          Comment

          Working...