Results 1 to 10 of 10
  1. #1
    Chuck55 is offline Novice
    Windows XP Access 2000
    Join Date
    Apr 2012
    Posts
    25

    Issues opening any c drive pdf with image control hyperlink property

    When clicking on the hyperlink to any c: drive pdf file


    - a msg box displays that opening the pdf might contain a virus (words to that affect). I have DoCmd.SetWarnings False
    - Clicking on the yes option opens Internet Explorer
    - - - a safety bar appears with text that the file is blocked from opening. At the end of the text is a button containing options (I did set the local intRAnet security to minimum with no affect).
    - - - Clicked on the open file option
    - - - acrobat reader opens inside IE
    - - - the pdf file opens
    - Opening the pdf also minimizes the access form.

    Can something be done so when the hyperlink to any c: drive pdf is clicked on
    - the access form will remain maximized
    - the possible virus msg does not open
    - Acrobat reader is opened and pdf file displayed without opening IE and being displayed inside IE

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I think there are a few things to consider, then you can determine what to try. These are my thoughts and may not be true. I don't use Adobe, nor Shell very often-- but my sample code works in Acc2003 on XP.

    I think if you use an Access form with a browser control, you can use the FollowHyperlink approach, but
    I think Adobe reader will opened by your browser in the browser area on the form.

    If you want to open Adobe reader from vba and avoid the (IE) browser, then you could use a shell command within your vba.

    Here is a vba proc that lets you open Adobe reader, and pass some parameters( page to open at start up) and keeps the Adobe open and your Access form will be open (although hidden by Adobe).

    Code:
    Option Explicit
    Option Compare Database
    
    
     'Declare the ShellExecute function by accessing the Shell library's procedure
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
    (ByVal hWnd As Long, ByVal lpszOp As String, _
    ByVal lpszFile As String, ByVal lpszParams As String, _
    ByVal LpszDir As String, ByVal FsShowCmd As Long) _
    As Long
     
     'Used to display a window 
    Const SW_SHOWNORMAL = 1
     
    'I'm sure there are other parameters and constants but this is what I found while answering your post.
     
    
    '---------------------------------------------------------------------------------------
    ' Procedure : OpenPDF
    ' Author    : Jack
    ' Date      : 07/05/2012
    ' Purpose   : To open Adobe Reader and show a pdf document without using FollowHyperlink
    '---------------------------------------------------------------------------------------
    '
    Sub OpenPDF(ByRef PDFPath As String, ByRef PdfName As String, Optional StartPage As String = "1")
        Dim strPath As String, strParam As String
         
       On Error GoTo OpenPDF_Error
    
        strPath = PDFPath & PdfName
        strParam = " /A " & Chr(34) & "page=" & StartPage & Chr(34) & strPath
         
        Call ShellExecute(0&, "open", "AcroRd32.exe", strParam, "", SW_SHOWNORMAL)
    
       On Error GoTo 0
       Exit Sub
    
    OpenPDF_Error:
    
        MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure OpenPDF of Module AdobeShellWithParms"
    End Sub
    Below is a routine to test the procedure
    Code:
    '---------------------------------------------------------------------------------------
    ' Procedure : testOpenPDF
    ' Author    : Jack
    ' Date      : 07/05/2012
    ' Purpose   : Routine to test OpenPDF
    '---------------------------------------------------------------------------------------
    '
    Sub testOpenPDF()
    Dim myPdf As String
    Dim MyPath As String
    
       On Error GoTo testOpenPDF_Error
    
    MyPath = "C:\Users\Jack\Documents\"
    myPdf = "rdbmsPrinciples.pdf"
      Call OpenPDF(MyPath, myPdf, "3")
    
       On Error GoTo 0
       Exit Sub
    
    testOpenPDF_Error:
    
        MsgBox "Error " & Err.number & " (" & Err.Description & ") in procedure testOpenPDF of Module AdobeShellWithParms"
    End Sub
    More info on ADOBE READER parameters at
    http://www.adobe.com/content/dam/Ado...parameters.pdf

  3. #3
    Chuck55 is offline Novice
    Windows XP Access 2000
    Join Date
    Apr 2012
    Posts
    25
    The code did not open the pdf. Was I correct in what I did as follows? I hard-coded MyPath and MyPDF to test with using the same file that opens when I click on the hyperlink. I created a command control and a line of code to call testopenPDF. I saved the form and closed it. I opened the form and clicked on the command button but nothing changed. I opened the code and put a stop on the command control line of code. I saved the change and closed the form. I opened the form, clicked on the command button and the code opened. I then stepped through the rest of the code pressing f8 with none of the error traps firing.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Did you save the code in the first Code box to a new module?
    Save the second code box to the same module.

    Adjust these parameters in the TestOpenPDF routine

    MyPath = "C:\Users\Jack\Documents\" <---------your path goes here
    myPdf = "rdbmsPrinciples.pdf" <--------------your pdf file name goes here

    If you aren't familiar with vba, can you zip your database and post it.
    Remove anything confidential.
    Just enough info to show the problem.

  5. #5
    Chuck55 is offline Novice
    Windows XP Access 2000
    Join Date
    Apr 2012
    Posts
    25
    I saved the first and second code boxes as new and separate modules.
    MyPath is set to the folder pathway of my c: drive (I copy/pasted from the table)
    MyPDF is the name of the file in the folder on my c: drive that MyPath is set to (I copy/pasted from the table)

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  7. #7
    Chuck55 is offline Novice
    Windows XP Access 2000
    Join Date
    Apr 2012
    Posts
    25
    what I described in post #5 is what I did in Post#3

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Do you have adobe Reader on your PC?
    Can you post the code you are using? Code behind the button and the modules containing the code I sent.

    Or make a small mdb with your form and modules and zip it along with your pdf, and post.


    I made a separate database, with a form with a button

    Code behind the button click event is
    Code:
    Private Sub btnClick_Click()
    On Error GoTo Err_btnClick_Click
    
     testOpenPDF
     
    Exit_btnClick_Click:
        Exit Sub
    
    Err_btnClick_Click:
        
        MsgBox Err.Description
        Resume Exit_btnClick_Click
        
    End Sub
    I have attached a jpg of the Form, and the opened pdf at Page 3.
    Attached Thumbnails Attached Thumbnails PdfSample.jpg  

  9. #9
    Chuck55 is offline Novice
    Windows XP Access 2000
    Join Date
    Apr 2012
    Posts
    25
    Problem solved. When you asked about Acrobat Reader, I use Acrobat (not Acrobat Reader) as my pdf reader also but it is an old version. Sometime back I removed the reader because I had problems creating pdf files with MS software when both were installed. I installed Reader 9, opened the access form and clicked on the command control. Acrobat Reader opened then the pdf displayed with the access form remaining maximized behind Acrobat Reader.

    I am so-so with VBA (started with COBOL back in the early 1980s) but no where close to what you do. What you provided is beyond my understanding. Your help was the critical final piece to my being able to complete a collection management mdb for a small museum in Colorado, where I am the director (as a volunteer).

    Thanks very much

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Glad you got it solved. And glad you got your project going. Post questions to the forum, or just do some searching, and follow the forum "conversations". It's a great way to learn and see how others do things.

    We're all volunteers here. I've been retired a few years.

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

Similar Threads

  1. Hyperlink Builder Issues - Paths vs Parameters
    By JeffG3209 in forum Programming
    Replies: 0
    Last Post: 08-16-2011, 02:17 AM
  2. Image List Control
    By Fredwards in forum Access
    Replies: 2
    Last Post: 11-23-2010, 10:30 PM
  3. syntax on setting image Picture control
    By cowboy in forum Reports
    Replies: 2
    Last Post: 02-18-2010, 10:00 AM
  4. Image control in MS Access
    By celestialcitizen in forum Forms
    Replies: 6
    Last Post: 07-03-2009, 03:25 PM
  5. Property Sheet issues
    By Tim in forum Access
    Replies: 1
    Last Post: 05-28-2009, 08:35 PM

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