• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

How save save website with a click?

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...
  • 2
  • 2
1 Solution
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
cwvsmartAuthor Commented:
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
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
It saves a file called google.htm on your c:\ drive as you requested...
cwvsmartAuthor Commented:
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

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now