Page 2 of 2 FirstFirst 12
Results 16 to 24 of 24
  1. #16
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Quote Originally Posted by June7 View Post
    Interesting, I tried setting BoundObjectFrame ControlSource to field with string path, also tried static text. Neither method displays object. So how is this accomplished in the sample db?
    Was thinking at first that perhaps you have hit upon an event limitation i.e. that it has to be the current event. However, I found that is not the case.
    There is a table with file path; short text field, a form with a textbox to show the path and code that references the textbox. I found that it works either on current (as designed) and on button click.
    Code:
     ' Specify source file.
        Me.OLEBound10.SourceDoc = CStr(Me.tbDocFile)
        ' Create link to.
        Me.OLEBound10.Action = acOLECreateLink
    The control is OLEbound as stated, with no Control Source or Source Item properties in design. I removed the initial Source Doc property and it still works. To test the button event, I simply move on to another record then click and it works. In spite of my implied notion that I wouldn't bother testing various types, I figured I may as well use the files that a different version came with since they're all in the same folder and dontcha know - it shows doc, pdf, xls and bmp. The pdf's load in a second, doc & xls take about 6.

  2. #17
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Tried your code. Worked for pdf. For other image types (png, jpg, ico) I get error "The OLE server isn't registered. To register the OLE server, reinstall it." I also get this annoying error when I try to close the form or switch to Design view even though the PDF displays just fine.

    I was also able to set SourceDoc to a string built in VBA, no textbox on form.
    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. #18
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Hmm. I don't experience any of those issues in 2016. Then again i haven't tried those image types yet.

  4. #19
    ironfelix717 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    150
    Hi all,

    Thanks for working on a solution.

    To clarify:

    I require an unbound control that I can set its source to a path (via string var - pulled from a table) to display the first page of the PDF as a preview. I do not wish to store any files or objects inside of a database, but reference the path - for space efficiency.

    The user will be able to click through files in, say, a listbox, consequently changing the object source path, thus providing a new preview for the file selected. The issue is not how to code this, the issue is finding a control that will accept VBA as an input to preview PDF files and idealy even JPEG, DOC, PNG, Excel, etc... I would be more than happy with just PDF and JPEG

    I am unsure of the OLE control you mention. Not sure if it will meet requirements above. It sounds like this control is bound.

    In the mean time, I am working on a Python solution that can be called from Shell in VBA. Not ideal solution.

    Thanks for your help

  5. #20
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    The code described in post 16 uses the BoundObjectFrame control but the control is not bound to field. Just as a textbox does not have to be bound to a field, this control does not either (as I learned via this thread).
    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.

  6. #21
    ironfelix717 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    150
    Hi all,

    The bound OLE control method does not work for some reason. Err 2719 "A problem occurred accessing the OLE Object".

    See attached sample.

    pdfPreviewSample.zip

  7. #22
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    This sort of works. It loads pdf but then I get annoying message "OLEServer isn't registered" and won't load another. This is probably why I've never used OLEObject dynamically.

    Code:
    Private Sub bLoad_Click()
    Dim file As Variant
    With Me
    .listFiles.RowSourceType = "value list"
    If Right(.tbSrc, 1) <> "\" Then .tbSrc = .tbSrc & "\"
    file = Dir(.tbSrc)
    While (file <> "")
        If file Like "*.pdf" Or file Like "*.jpg" Then
            .listFiles.AddItem file
        End If
        file = Dir
    Wend
    End With
    End Sub
    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.

  8. #23
    ironfelix717 is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Oct 2018
    Posts
    150
    So it appears there is no control to display the preview dynamically for files....

    I guess I must resort to converting PDFs to images via another language or ideally VBA if I can find something (doubtful) and loading in image control.

  9. #24
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Correct. Image control can dynamically display jpg, bmp, png, ico - not PDF. There may be some third-party developed control that could display PDF but implementing that would open its own can-of-worms issues.

    Conversion coding in Access VBA is not simple. All code I can find requires installation of Adobe Acrobat, not just the Reader. https://myengineeringworld.net/2013/...iles-into.html

    There are many on-line services https://pdf2jpg.net/
    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.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 07-05-2018, 06:42 AM
  2. Show thumbnail for video on MS Access form
    By gem1204 in forum Forms
    Replies: 10
    Last Post: 09-19-2016, 10:30 AM
  3. Access Solution Inquiry
    By JeRz in forum Access
    Replies: 5
    Last Post: 09-06-2016, 07:01 AM
  4. Converting an Excel Solution to Access
    By rockym567 in forum Database Design
    Replies: 3
    Last Post: 05-13-2016, 05:17 AM
  5. Replies: 8
    Last Post: 11-10-2014, 01:25 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