Solved

Access Web Browser - copy contents

Posted on 2013-01-29
8
253 Views
Last Modified: 2013-01-30
Dear Experts

I have a form with a built in WebBrowser ("WebBrowser3") - this displays a QR code (a vCard) which has been generated from various fields in the data base.  What is displayed is a .png picture which has been generated from http://chart.apis.google.com

What I'd like to do is write a piece of code that copies that picture and saves it to my desktop - in effect the same as doing the following ... Right Click on the webbrowser & "Save Picture as"

Can anybody help?
0
Comment
Question by:correlate
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 40

Expert Comment

by:als315
ID: 38832069
I think you can do it in two steps:
1. Find picture's url. Sample you can find here:
http://www.vbforums.com/showthread.php?384076-Webbrowser-Control-Tip-and-Examples
2. Download it and save with UrlDowndoadToFile:
http://stackoverflow.com/questions/12269941/vba-urldownloadtofile-data-missing-in-downloaded-file
0
 

Author Comment

by:correlate
ID: 38832559
Looks perfect, will need to test it put tomorrow when I'm back at my PC.
0
 

Author Comment

by:correlate
ID: 38834597
Hi Thanks for this, alas I cant get it to work & I get an error pointing to this line:

   Ret = URLDownloadToFile(0, strURL, strPath, 0, 0)

The code I have is as follows:

In the form:
Public Sub DownloadMeFile_Click()
  
Dim QRString As String
Dim QRString1 As String
Dim QRString2 As String

QRString1 = "http://chart.apis.google.com/chart?cht=qr&chs=350x350&chld=L&choe=UTF-8&chl=BEGIN%3AVCARD%0AN%3A"
QRString2 = Me.[Gen-FullName] & "%0AORG%3AArcus Global Partners%0ATITLE%3A" & Me.[Gen-JobTitle] & "%0ATEL%3A" & Me.[Card-QRPhoneUsed] & "%0AURL%3A" & Me.[Card-URL] & "%0AEMAIL%3A" & Me.[Gen-WorkEmail] & "%0AADR%3A" & Me.[Card-QROffice Address] & "%0ANOTE%3A" & Me.[Card-QRNote] & "%0AEND%3AVCARD"
QRString2 = Replace(Replace(QRString2, "+44 (0)", "0"), " ", "+")
QRString2 = Replace(Replace(QRString2, "@", "%40"), "/", "%2F")
QRString2 = Replace(Replace(QRString2, ":", "%3a"), "/", "%2F")
QRString = QRString1 & QRString2

  
Dim strURL As String
    Dim strPath As String

    strURL = QRString

    strPath = "C:\Users\tcrowfoot\Desktop\test.png"

    Ret = URLDownloadToFile(0, strURL, strPath, 0, 0)

    If Ret = 0 Then
        MsgBox "File successfully downloaded"
    Else
        MsgBox "Unable to download the file"
    End If

End Sub

Open in new window


In a Module
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

Dim Ret As Long

Open in new window


These are the full codes, so not sure if im being thick / missing anything
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 40

Expert Comment

by:als315
ID: 38834676
I can't test you real picture, but file EE logo is downloaded without problems. Look at sample. Declaration was modified for 64 bit and 32 bit os.
DBWeb1.accdb
0
 

Author Comment

by:correlate
ID: 38834726
Hi

Many thanks for this,

I added a form to your sample to fire it up from & unfortunately I'm still getting the same error message: "Sub or Function not defined" pointing to Ret = URLDownloadToFile(0, strURL, strPath, 0, 0)

My pc is 64bit

I have attached my version of your sample, would you be able to take a look at it?
DBWeb1.accdb
0
 

Author Comment

by:correlate
ID: 38834740
Hi

Just spotted that i was missing the URL, have out that back in, but alas still get the same problems - new version attached
DBWeb1.accdb
0
 
LVL 40

Accepted Solution

by:
als315 earned 500 total points
ID: 38834985
In your case you need declare function as Public
DBWeb1.accdb
0
 

Author Closing Comment

by:correlate
ID: 38836070
Brilliant - thank you very much - it works a treat!
0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question