Access/Acrobat PDF Viewer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Fred Ho
    New Member
    • Oct 2007
    • 18

    Access/Acrobat PDF Viewer

    I have an access database which has some text box as for input search citeria and a continous subform to display the search result.
    Pls teach me in steps how to add a viewer (or active x control element) to see the corresponding pdf file link to the record.
    Suppose the records in the ProjectRecord Form and has a field called imagelink which have the path of the pdf file.
    Wish to have the code shown.
    Thanks!
  • sierra7
    Recognized Expert Contributor
    • Sep 2007
    • 446

    #2
    Hi
    Assuming you have a command button called Command1 and can read the path and file name of the PDF document from a TextBox you will need something like this on the Click event.

    Code:
     
    Private Sub Command1_Click()
    On Error GoTo Err_Command1_Click
    	Dim stAppName As String
    	Dim stPathFileName As String
     
    	'Define path and file name of PDF document, keep .pdf extention
    	stPathFileName = Me!txtPathFile
    	stAppName = "C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe " & stPathFileName
    	Call Shell(stAppName, 1)
     
    Exit_Command1_Click:
    	Exit Sub 
    Err_Command1_Click:
    	MsgBox Err.Description
    	Resume Exit_Command1_Click
     
    End Sub
    This obviously depends where your Acrobat reader file is located

    S7

    Comment

    • Fred Ho
      New Member
      • Oct 2007
      • 18

      #3
      If I have to add the active x for pdf file at the main form to display the first row of record at the subform, can it be done? or I have to click the row of record at the subform then display the corresponding pdf at the active x display? (The subform consists of a row of scroll down text boxes...)
      How to do that in steps?
      Besides, will it be a lot of acrobat buttons occupy the screen when I use the active x to open the pdf file at the main form? Can I control that just like for the tiff and jpg viewer (just picture and no other button eg zoom...etc.)?
      For time being, I think I will need:
      1. add the active x at the main form
      2. I may need a code to add the text boxes (may be for the click event)...
      3...
      then I dont know how to make the code and also how to make the active x know how to display the corresponding pdf file when the user scroll down the subform or click the text box at the subform.
      Hope that you can understand and really looking for any kindly help!
      Thanks once again!

      Comment

      • sierra7
        Recognized Expert Contributor
        • Sep 2007
        • 446

        #4
        Hi Jo

        The code I showed in my last post was to start-up Adobe Acrobat in a separate window and automatically display the document specified in the Path. I thought it best to associate a command button with each record and then click to display the document as needed. This works.

        I was not using ActiveX components and not trying to display the document inside a window/box/control on a form. My assumption being that a PDF file would be trying to show one or more A4/Letter size pages which would not be easy to read in a small window.

        I'm sure there may well be ActiveX products that can be added into Access to allow displaying PDF's in an 'Image Control'; I've never needed to look for one, but I would expect instructions how to use it to be provided by the software supplier.

        I will look into this further and am currently checking AcroPDF.dll
        S7

        Comment

        • Fred Ho
          New Member
          • Oct 2007
          • 18

          #5
          Thanks for the previous suggestion!
          I have add a preview button at the subform and insert a OLE1 object at the main form call ProjectDrawingF orm.

          Private Sub Preview_Click()
          OLE1.Class = "Adobe Acrobat 7.0"
          OLE1.OLETypeAll owed = acOLELinkedOLE1 .SourceDoc = "C:\xnview\ " & Form![Text 14].value &".pdf
          OLE1.Action = acOLECreateLink
          OLE1.SizeMode = acOLESizeZoom
          End Sub

          (change to following)
          Private Sub Preview_Click()
          Form_ProjectDra wingForm.OLE1.C lass = "Adobe Acrobat 7.0"
          Form_ProjectDra wingForm.OLE1.O LETypeAllowed = acOLELinked
          Form_ProjectDra wingForm.OLE1.S ourceDoc = "G:\AsBuilt\C\C 001\1135_0A.pdf "
          Form_ProjectDra wingForm.OLE1.A ction = acOLECreateLink
          Form_ProjectDra wingForm.OLE1.S izeMode = acOLESizeZoom
          End Sub

          why the OLE1.Action cannot work ?
          Besides,for the SourceDoc, such as Form_ProjectDra wingForm.OLE1.S ourceDoc = "G:\AsBuilt\C\C 001\1135_0A.pdf " the source "G:\AsBuilt\C\C 001\1135_0A.pdf "should be extract from the table ProjtectDrawing Record and inside a field called ImageLink
          But need to change as
          (original field look like):> file:\\G:\AsBui lt\C\C001\1135_ 0A.pdf
          (so I need to extract the info look like):>G:\AsBui lt\C\C001\1135_ 0A.pdf
          what will be the code look like for such function?
          Thanks a lot!

          Comment

          • FishVal
            Recognized Expert Specialist
            • Jun 2007
            • 2656

            #6
            As an additional option you may try WebBrowser ActiveX control on your form.
            Using its Navigate method smoothly populates it with an external pdf file.
            Acrobat ActiveX control usually makes troubles.

            Regards,
            Fish

            Comment

            • Fred Ho
              New Member
              • Oct 2007
              • 18

              #7
              I have sucessfully added the OLE bounded object at the main form.
              The OLE will display the pdf file when the preview button at the subform is clicked with the following codes:

              Private Sub Preview_Click()
              Form_ProjectDra wingForm.OLE1.C lass = "Adobe Acrobat 7.0"
              Form_ProjectDra wingForm.OLE1.O LETypeAllowed = acOLELinked
              Form_ProjectDra wingForm.OLE1.S ourceDoc = Me!ImageLink.Va lue
              Form_ProjectDra wingForm.OLE1.A ction = acOLECreateLink
              Form_ProjectDra wingForm.OLE1.S izeMode = acOLESizeZoom
              End Sub

              I have problem here:
              1. what will be the code change if the value Me!ImageLink.Va lue (the value is in fact the full path of the pdf file e.g. g:\abc\abc.pdf) is empty or the path is wrong or the file is not exists and let the OLE object display back as a blank white?
              2. in fact, there is a reset button in the main form, what code I should add so that the OLE object can reset to blank.
              Thanks!

              Comment

              • sierra7
                Recognized Expert Contributor
                • Sep 2007
                • 446

                #8
                Hi

                This looks interesting and I must try it when I get time!

                If it works as well as it sounds I would be tempted to have an extra PDF file in the system bearing text saying "Document Not Available" and display that file if
                Me!ImageLink.Va lue was Null, thereby avoiding the problem of an empty OLE control.

                S7

                Comment

                Working...