Results 1 to 10 of 10
  1. #1
    hilfesucher is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2015
    Posts
    5

    PDF displaying in Form

    Hello,

    I am currently having a form that have a textbox field, a command button. I am trying to find a code to so that I can open or display a PDF file in a form.
    What I need is a Code to open various PDF file from the folder (the folder is called “PDF”) is located in “C:\Users\RU\Desktop\PDF”.
    When I write the name of the PDF in the textbox and click the button, the PDF loads directly in Form and if the PDF name is not found in the folder then the message box "File not exist" should appear.

    Any help would be greatly appreciated
    Thanks,

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Think requires Web Browser control to display PDF file.

    Bing: Access database display pdf in form

    http://stackoverflow.com/questions/1...tent-on-a-form

    Also, https://www.accessforums.net/access/...ive-41691.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    hilfesucher is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2015
    Posts
    5
    Hello June7,
    I have access 2007,where can I find the "WebBrowser Control"?
    thanks
    Click image for larger version. 

Name:	foto.JPG 
Views:	22 
Size:	25.5 KB 
ID:	22543

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I don't remember. Never used it.

    Bing: Access 2007 web browser control

    http://bytes.com/topic/access/answer...-access-2007-a
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    hilfesucher is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2015
    Posts
    5

    code for Textbox and PDF displaying

    Hello,

    I am currently having a form that have a textbox field, a command button. I am trying to find a code to so that I can open or display a PDF file in a form.
    What I need is a Code to open various PDF file from the folder (the folder is called “PDF”) is located in “C:\Users\RU\Desktop\PDF”.
    When I write the name of the PDF in the textbox and click the button, the PDF loads directly in Form and if the PDF name is not found in the folder then the message box "File not exist" should appear.

    I insert the following code in the button but it not works:

    Private Sub CommandButton1_Click()
    Dim myPath As String
    Dim myfile As String

    myfile = "C:\Users\RU\Desktop\PDF\" & Me.TextBox1.Text & ".PDF"
    Shell & myfile, vbNormalFocus
    End Sub



    Any help will be greatly appreciated

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Merged threads.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 8 Access 2013
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    Quote Originally Posted by hilfesucher View Post
    Hello,

    I am currently having a form that have a textbox field, a command button. I am trying to find a code to so that I can open or display a PDF file in a form.
    What I need is a Code to open various PDF file from the folder (the folder is called “PDF”) is located in “C:\Users\RU\Desktop\PDF”.
    When I write the name of the PDF in the textbox and click the button, the PDF loads directly in Form and if the PDF name is not found in the folder then the message box "File not exist" should appear.

    I insert the following code in the button but it not works:

    Private Sub CommandButton1_Click()
    Dim myPath As String
    Dim myfile As String

    myfile = "C:\Users\RU\Desktop\PDF\" & Me.TextBox1.Text & ".PDF"
    Shell & myfile, vbNormalFocus
    End Sub



    Any help will be greatly appreciated
    The Shell command is used to run programs. It does not understand files extension and how to open the associated program. To use Shell you must include the path to the application (exe) before the file name.

    You will need to use ShellExec if you want to pass only a file. I have created this example that shows how to use it: Document Links (Click Here)

    Note: Using Shell or ShellExec will open the PDF in a separate application not on the form.

    The native (built-in) Web Browser Contriol (WBC) was added in Access 2010. It can be used to view the the PDF directly on a form. In 2007 and earlier you have to use teh WBC ActiveX control.

    My users say it is difficult to read a PDF when on a form. They prefer opening it in a PDF viewer.

  8. #8
    hilfesucher is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2015
    Posts
    5
    Hello HiTechCoach,
    and thank you for your help
    I want to ask if you can tell me please, how the code should be if I want to write in the textbox the name of File and not the File Path.

    Thank you in advance for your help

  9. #9
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 8 Access 2013
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    705
    Quote Originally Posted by hilfesucher View Post
    Hello HiTechCoach,
    and thank you for your help
    I want to ask if you can tell me please, how the code should be if I want to write in the textbox the name of File and not the File Path.

    Thank you in advance for your help
    It looks like you already have that figured out:

    From you post (#5)
    Code:
    myfile = "C:\Users\RU\Desktop\PDF\" & Me.TextBox1.Text & ".PDF"

  10. #10
    NTC is offline VIP
    Windows 7 64bit Access 2013
    Join Date
    Nov 2009
    Posts
    2,392
    Whenever one attempts to window an application (Adobe PDF in this case) inside a database form - it is problematic. This question comes up routinely also involving Word, Excel, etc. If you are trying to display a passive single page image - then exporting the pdf to a jpg or bmp or something and relying on the image control is the way to go. But the Adobe PDF application is overall quite sophisticated - so if you wish to use its full features and functions one should generally not be windowing it thru a database form but instead rely on the operating system - the true 'Windows' solution....to launch the application outside of the database....

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 07-04-2015, 02:55 PM
  2. Replies: 3
    Last Post: 08-26-2014, 12:52 PM
  3. Replies: 10
    Last Post: 10-14-2013, 10:18 AM
  4. Replies: 1
    Last Post: 11-12-2010, 06:33 PM
  5. Replies: 1
    Last Post: 11-07-2010, 11:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums