How save save website with a click?

Posted on 2003-03-12
Medium Priority
Last Modified: 2010-05-01
I'd develop a form that when user click a button, it actually open the web browser(separate window) with specific URL.

My question is:
How to save specific website onto some temp folder in VB environment?

I know i can do it manually by right click hyperlink and choose "save target as". I tried using WINDOW API and hwnd..It's too troublesome and time consuming and not sure whether i'm on the correct path.

Just in case my way of explanation is too confusing. (Sorry for the broken english)
1)User clicked button A on a form.
2)Button A invoke another window(web browser->IE) pop up with pre-defined URL.
3)User click a hyperlink on the IE
4)Now user wish to save the web(have to manually right click and choose "save target as..."

My aim is to automate the process 3 and 4 for user:meaning when user click a button B or user drag cursor to current web/active window, from there suppose to invoke save the web/html function directly onto a temp folder.

Any comment or suggestion would be greatly appreciated...
Question by:cwvsmart
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
  • 2
  • 2
LVL 14

Accepted Solution

aelatik earned 500 total points
ID: 8125536
This will do the job....

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 DownloadFile(URL As String, LocalFilename As String) As Boolean
    Dim lngRetVal As Long
    lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)
    If lngRetVal = 0 Then DownloadFile = True
End Function
Private Sub Form_Load()
    DownloadFile "http://www.google.com", "c:\google.htm"
End Sub

Happy programming :)
Ayhan Elatik

Author Comment

ID: 8125862
I'm sorry..Ayhan Elatik but i'm a bit slow in this...what happen? when i implement the codes...Nothing happens..Do i need to include any other additional references?

Thank you

Expert Comment

ID: 8149022
A request for deletion has been made.  If no response or you feel this is in error, comment.  If no objection, I will delete in three days.

E-E Admin
LVL 14

Expert Comment

ID: 8153568
It saves a file called google.htm on your c:\ drive as you requested...

Author Comment

ID: 8156421
Thank you Aelatik. I'm not sure what happened the other day when i test out your codes. I must be too tired.....

Thank you and your help is greatly appreciated.

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month12 days, 1 hour left to enroll

752 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