Solved

Access Web Browser - copy contents

Posted on 2013-01-29
8
251 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
  • 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
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…

830 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