Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2003
    Location
    Cleveland USA
    Posts
    184

    Angry Unanswered: Display PDF in a report - OLE or activeX?

    This is related to my prior post regarding displaying PDFs in a form. Now I need to display PDFs in a report, which is a hair-pulling frustrating mystery!

    Through research, I found that you cannot change the source of an unbound OLE (or is it bound? I've tried both!) in a report, so the way I did it on the form will not work.

    So, I decided to try an activeX control. When using the AdobeReader type, I tried this code to set the source (string variable sPath):

    Me.ctlAdobe.Object.src = sPath
    Me.ctlAdobe.src = sPath

    When I open the report, nothing happens! The control is blank and I don't get an error. I did verify that it's hitting the code and "sPath" contains the full path and file name.

    Next I tried a web browser activeX control with:

    ctlDrawing.Object.Navigate (sPath)

    Once again, nothing happened. Control is blank, no error message, stepping through code doesn't show any problems.

    HELP! Is there something missing here?

  2. #2
    Join Date
    Apr 2013
    Posts
    9

    Did you find a solution

    Quote Originally Posted by LisaChow View Post
    This is related to my prior post regarding displaying PDFs in a form. Now I need to display PDFs in a report, which is a hair-pulling frustrating mystery!

    Through research, I found that you cannot change the source of an unbound OLE (or is it bound? I've tried both!) in a report, so the way I did it on the form will not work.

    So, I decided to try an activeX control. When using the AdobeReader type, I tried this code to set the source (string variable sPath):

    Me.ctlAdobe.Object.src = sPath
    Me.ctlAdobe.src = sPath

    When I open the report, nothing happens! The control is blank and I don't get an error. I did verify that it's hitting the code and "sPath" contains the full path and file name.

    Next I tried a web browser activeX control with:

    ctlDrawing.Object.Navigate (sPath)

    Once again, nothing happened. Control is blank, no error message, stepping through code doesn't show any problems.

    HELP! Is there something missing here?

    ---------
    I now have same problem many years later did you find a solution??

    If so I would love to have your tips!

    thx

  3. #3
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    495
    Provided Answers: 24
    Stop pulling your hair. There's no need to re-invent the wheel.
    Just let the pdf open in it's own reader. (no headaches)

    Paste this code into a module and call the pdf (or ANY file): OpenNativeApp sFilePath

    Code:
    Option Compare Database
    Option Explicit
    
    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
    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    Const SW_SHOWNORMAL = 1
    Const SE_ERR_FNF = 2&
    Const SE_ERR_PNF = 3&
    Const SE_ERR_ACCESSDENIED = 5&
    Const SE_ERR_OOM = 8&
    Const SE_ERR_DLLNOTFOUND = 32&
    Const SE_ERR_SHARE = 26&
    Const SE_ERR_ASSOCINCOMPLETE = 27&
    Const SE_ERR_DDETIMEOUT = 28&
    Const SE_ERR_DDEFAIL = 29&
    Const SE_ERR_DDEBUSY = 30&
    Const SE_ERR_NOASSOC = 31&
    Const ERROR_BAD_FORMAT = 11&
    
    
    Public Sub OpenNativeApp(ByVal psDocName As String)
    Dim r As Long, msg As String
    
    r = StartDoc(psDocName)
    If r <= 32 Then
        'There was an error
        Select Case r
            Case SE_ERR_FNF
                msg = "File not found"
            Case SE_ERR_PNF
                msg = "Path not found"
            Case SE_ERR_ACCESSDENIED
                msg = "Access denied"
            Case SE_ERR_OOM
                msg = "Out of memory"
            Case SE_ERR_DLLNOTFOUND
                msg = "DLL not found"
            Case SE_ERR_SHARE
                msg = "A sharing violation occurred"
            Case SE_ERR_ASSOCINCOMPLETE
                msg = "Incomplete or invalid file association"
            Case SE_ERR_DDETIMEOUT
                msg = "DDE Time out"
            Case SE_ERR_DDEFAIL
                msg = "DDE transaction failed"
            Case SE_ERR_DDEBUSY
                msg = "DDE busy"
            Case SE_ERR_NOASSOC
                msg = "No association for file extension"
            Case ERROR_BAD_FORMAT
                msg = "Invalid EXE file or error in EXE image"
            Case Else
                msg = "Unknown error"
        End Select
    '    MsgBox msg
    End If
    End Sub
    
    Private Function StartDoc(psDocName As String) As Long
    Dim Scr_hDC As Long
    
    Scr_hDC = GetDesktopWindow()
    StartDoc = ShellExecute(Scr_hDC, "Open", psDocName, "", "C:\", SW_SHOWNORMAL)
    End Function

  4. #4
    Join Date
    Apr 2013
    Posts
    9

    Display PDF in a report - OLE or activeX?

    Thanks .. I have pulled so much hair, so I will take a rest and look at it later.

    For now thx a lot .. have a great day

  5. #5
    Join Date
    Apr 2013
    Posts
    9
    Hi
    Your program line is great to open Adobe in this case

    Problem is not that I can not open the PDF in report . separately

    the problem is that the first part of my report is MS access with details and I need to show a pdf file of the various pictures (in PDF) at the end of my report. I have 3 options

    1. Merge two PDF files when report is re-printed to PDF
    2. Convert my label PDF into jpg then view it in report
    3. Try to update some how latest PDF into last section of my report.

    I have 800 various products and descriptions, they need to be updated at the end of my report.. However I can not re-read latest PDF file for each product. If I use one reference f.ex Product1234, if i change to Product1235 it is not updateable!

    Hope you understand and can guide me

    thx for now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •