Automate saving a webpage

Posted on 2004-11-15
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?
Question by:TriggerHappy
    LVL 5

    Expert Comment


    - Joe
    LVL 17

    Accepted Solution

    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"

    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.

    Expert Comment

    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
    GetInternetFile = False
        Resume 105
    105 End Function

    then just call the function like so

    GetInternetFile frmMain.Inet1, "","filenametosaveto.ext"
    LVL 9

    Author Comment

    Wow...that was perfect...

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

    Expert Comment

    Am I missing something here...what does the inet1 argument mean?

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Vb6 rich textbox tab 10 53
    How to create a duplicate finder Application 9 73
    Windows 10 start screen issues 9 39
    VBA filters 2 24
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
    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…
    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…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now