Display a Web Image in a Report
Display a Web Image in a Report
(OP)
Hi Folks,
THERE MUST BE A WAY TO DO THIS!!
Our organization has images on the web (actually, SharePoint server). I have managed to display the images on a form using a Web Browser Control. However, I cannot figure out how to display a web image on a report. A Web Browser Control does not work on reports; only forms.
I have two fields: one storing the URL path (Http://site/library/), and the other storing the image name. By concatenating the together, I get the entire path.
This should be far easier than it is. The images must stay on the web (per organization policy), so storing locally is not an option.
Ideas? Thank you in advance.
THERE MUST BE A WAY TO DO THIS!!
Our organization has images on the web (actually, SharePoint server). I have managed to display the images on a form using a Web Browser Control. However, I cannot figure out how to display a web image on a report. A Web Browser Control does not work on reports; only forms.
I have two fields: one storing the URL path (Http://site/library/), and the other storing the image name. By concatenating the together, I get the entire path.
This should be far easier than it is. The images must stay on the web (per organization policy), so storing locally is not an option.
Ideas? Thank you in advance.
RE: Display a Web Image in a Report
Web-browsers can process URLs - reports can't (neither can forms - that's why you embed a 'pretendy' web browser).
You can't do this with ANY OTHER application - why do you expect an MS Access report to do it?
Can you point me to ANY (non-browser) application that enables you to treat a URL path like a physical file path?
As this is a company owned web-site, you have an option of referring to the physical, server file path to the image (that the web-site uses).
This has an advantage of: when the web image changes - so will yours (because the physical file will change).
If there are 'permissions' issues with that, then the company needs to revise it's policy, because it's business processes are failing because of it.
It should be that all images are stored in one place, centrally, and all applications / web-pages access the same images OR, there is a process of storing the same images in multiple locations and maintaining their topicality.
I find that policy to be strange, have you personally read it or has someone 'told you it is so'?
I'd personally find and read the 'policy'.
ATB,
Darrylle
Never argue with an idiot, he'll bring you down to his level - then beat you with experience.
RE: Display a Web Image in a Report
So what?
> reports can't [process URLs ]
Sure they can, just not completely natively.
>Can you point me to ANY (non-browser) application that enables you to treat a URL path like a physical file path?
There are plenty - media players, for example.
We can make Access handle an image URL as a displayable file path pretty easily, even on a Report
Simple example
1) Stick an MSForms Image control on your report (we'll assume it is called Image0)
2) Add an event procedure to the OnFormat event for the report section the control is on
3) The code should look like (this is for the Detail section). Note that Report_Load might be a better event to use if you want to see the image in all report views apart from Design View (i.e. layout, print preview and report)
CODE
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) Set Image0.Picture = LoadPictureFromURL("http://www.blogcdn.com/www.engadget.com/media/2012/03/nokia-n9-inception.jpg") SOurce file - this text could obviously come from a field in a table, for example End Sub
4) Create the following function in a module:
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
Now print preview your report (after saving it)
RE: Display a Web Image in a Report