Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Printing a web image in a report

Printing a web image in a report

Printing a web image in a report

I am trying to follow the directions from strongm in the previous closed thread:

thread703-1758167: Display a Web Image in a Report

It doesn't appear to be working for me, probably because there is something I don't understand. I'm a power user, not really a programmer. After setting the format event on the group header section, and creating and saving the function in the module, nothing appears in the report. I suspect it may be related to my not knowing how to switch from the example URL to the field URL. The original that strongm posted was:
Set Image0.Picture = LoadPictureFromURL("http://www.blogcdn.com/www.engadget.com/media/2012...") SOurce file - this text could obviously come from a field in a table, for example
I have tried two ways to use the URL from the field in the table. The first won't run at all and gives me a picture1web not found error.
Set Image0.Picture = LoadPictureFromURL([picture1web])

The second will let me see the report, but the picture doesn't appear and if I try to preview or print the report I get an error that says a custom macros has failed to run preventing the report from rendering.
Set Image0.Picture = LoadPictureFromURL("[picture1web]")

The problem might also be that I did the module wrong. I've never added a module to a database before other than to add events to forms. Can anyone help shed some light on this issue?

If not, does anyone have any ideas for me? I just want to print a program guide of workshop leaders names, bios, picture, and workshop descriptions in a book. All of the pictures of the people have been loaded into an Access 2013 database. I can view a form on the screen with the pictures in it, but it won't print. I haven't been able to get the report to show the pictures either (insofar that the web browser object is not supported in reports). I've tried doing a Word Merge, but it just posts the URL and not the picture. If I could figure out how to do it in HTML I would try that, but as I noted, I'm not a real programmer.

Any help would be greatly appreciated.

CJ Rhoads

RE: Printing a web image in a report

You probably need to confirm the exact contents of [picture1web] that fails, and let us know what it is.

RE: Printing a web image in a report

I had exactly the same problem with the supplied code.

I found this alternative code which worked perfectly for many online images

CODE -->

Option Compare Database
Option Explicit

Private Declare Function CLSIDFromString Lib "ole32" (ByVal lpstrCLSID As Long, lpCLSID As Any) As Long
Private Declare Function OleLoadPicturePath Lib "oleaut32" (ByVal szURLorPath As Long, ByVal punkCaller As Long, ByVal dwReserved As Long, ByVal clrReserved As OLE_COLOR, ByRef riid As Any, ByRef ppvRet As Any) As Long

Public Function LoadPictureFromURL(ByVal url As String) As Picture
    Dim IPic(15) As Byte 'holds the IPicture interface
    CLSIDFromString StrPtr("{7BF80980-BF32-101A-8BBB-00AA00300CAB}"), IPic(0)
    OleLoadPicturePath StrPtr(url), 0&, 0&, 0&, IPic(0), LoadPictureFromURL
End Function 

Unfortunatley it was no use for the 'static' online maps I wanted but I used Google Maps API instead & it worked perfectly
See this thread: Show Web Image in Report

RE: Printing a web image in a report

Thanks, ridders52. I'll try it and let you know.

Also, strongm, the contents of pictureweb1 was on my own website: http://hplconsortium.com/cld/ldr/RHOADCJ331/CJRhoa..., for example. The URL works fine in the form, so I'm sure there is nothing wrong with the URL. It is a hyperlink type, although I have the text itself stored in another field I called pictureweb1text, but that didn't work either.

CJ Rhoads

RE: Printing a web image in a report

>I found this alternative code

As I pointed out in the other thread, it is the exact same code. My code. Not an alternative. The same.

By the way, the URL you have provided currently does not point to an image file, it goes to 1 404 page. At least it does when I feed it into Edge or IE. So, again, my code - designed to download a image - won't work. So I'll assume that you tested the URL when there was an image there. But my point was really to gently prod you to see whether you really meant

Set Image0.Picture = LoadPictureFromURL("[picture1web]")

which is not passing the contents of the field as the URL, it is passing the fieldname itself (as the error message you were getting was trying to tell you)

However, as I pointed out to ridders52 in his thread, there is a bit of critical info missing in my code - the Image control needs to be the MS Forms ActiveX image control, not the Access image control since the Access control does not directly expose any of the OLE Picture interfaces

RE: Printing a web image in a report

Apologies to @strongm.

Below is a copy of my own reply from my own thread (hopefully I can at least get that right!) bigsmile
It was late & I copied / pasted your code as you correctly pointed out.
Just to make things worse, I tried to be 'helpful' by also pasting in the other thread

OK - the alternative code I found (can't remember where or the author) is as follows:

CODE -->

Option Compare Database
Option Explicit

Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
                                           "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal _
                                                                                                               szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long

Public Function DownloadFilefromWeb(url As String, fileName As String) As Boolean
    DownloadFilefromWeb = URLDownloadToFile(0, url, fileName, 0, 0)
End Function 

That does work correctly with a standard Access image control on standard web images such as the link in strongm's post.
I used that code to download the 'static' map image defined using Google Maps API

I've also re-tested strongm's code using the ActiveX MS Forms image control & his example image & it works perfectly

RE: Printing a web image in a report

Yep, perfectly reasonable alternative, with the caveat that it requires an intermediary step (saving the file locally before it can be loaded into the control)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close