Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access Web Browser - copy contents

Posted on 2013-01-29
8
Medium Priority
?
254 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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 2000 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

10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

Question has a verified solution.

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

We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

721 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