?
Solved

Automate saving a webpage

Posted on 2004-11-15
5
Medium Priority
?
1,733 Views
Last Modified: 2012-02-15
I have a visual basic app that is supposed to open a webpage, open a webpage and automatically save it to a local directory.

The problem is that when i initiate the save webpage command, it still opens the dialog box as to where to save the webpage.

Here is the code that I use to start the save.

WebBrowser1.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DONTPROMPTUSER, FileName + "CaseID " + CsrList(i) + ".htm"

What is the point of dontpromptuser if a dialog box still shows up?

Secondly, how do i get around this problem?
0
Comment
Question by:TriggerHappy
5 Comments
 
LVL 5

Expert Comment

by:jpontani
ID: 12587542
Instead of OLECMDID_SAVEAS, try OLECMDID_SAVE.

- Joe
0
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 1000 total points
ID: 12589285
SAVE/SAVEAS act as the options from the "File" menu do. You can only use SAVE if you've previously saved.

"How To Download a File Without Prompting"
http://support.microsoft.com/kb/q244757/

SUMMARY
The WebBrowser control and Internet Explorer have Save and Save As options that can be used to save files using the ExecWB command. However, this involves prompting from the user. There is no way to suppress this prompt. To save files to the hard-disk without prompting, use the URLDownloadToFile API from URLMON.
0
 

Expert Comment

by:WackoMike
ID: 12590412
I just posted how to do this in a different topic but I am sure this is what you need.

you can always just use the Microsoft Internet Trasnfer Control it should do what you want here is a example of how to download a file

Global myVer As String
Global status$
Global UpdateTime As Integer

Public Function GetInternetFile(Inet1 As Inet, myURL As String, file As String) As Boolean
    ' Written by: Blake Pell
   
    On Local Error GoTo 100
   
    Dim myData() As Byte
    Dim str As String
    Dim x As Long
    If Inet1.StillExecuting = True Then Exit Function
    myData() = Inet1.OpenURL(myURL, icByteArray)


 
    myFile$ = App.Path & "/" & file
    Open myFile$ For Binary Access Write As #1
    Put #1, , myData()
    Close #1
   
    GetInternetFile = True
    Exit Function

' error handler
100
GetInternetFile = False
    Resume 105
105 End Function



then just call the function like so


GetInternetFile frmMain.Inet1, "www.sitetofile.com/file.ext","filenametosaveto.ext"
0
 
LVL 9

Author Comment

by:TriggerHappy
ID: 12598743
Wow...that was perfect...

Sorry for the long wait, but had other work to finish before i could test this solution.
0
 
LVL 1

Expert Comment

by:MrExcel1981
ID: 25390936
Am I missing something here...what does the inet1 argument mean?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

850 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