Shellexecute Opens HTML first time but fails to reload when called again

Posted on 2006-05-01
Last Modified: 2010-04-07
I am trying to refresh a webpage from within a VB program. The first call opens the page successfully, however when Shellexecute is called again, the page is not refreshed (it contains the same page from the first call)

How do I force a reload (like when i click the refresh toolbar button in the explorer browser)

Question by:const71
    LVL 4

    Accepted Solution

    Try using InternetExplorer object.

    Go to the menu: Project -> References
    Find and add "Microsoft Internet Controls"

    Declare the following so it can be used by open and refresh methods:

        Dim objIE As InternetExplorer

    Then use the following code to open the internet explorer with the HTML.

        Set objIE = New InternetExplorer
        objIE.Navigate "http://yourpage"

    When you refresh just use:    
    LVL 6

    Expert Comment

    Just put 3 buttons on a form and try the following code:

    Dim objIE As Object

    Private Sub Command1_Click()
        Set objIE = CreateObject("InternetExplorer.Application")
        objIE.Visible = True
        objIE.Navigate2 ("")
    End Sub

    Private Sub Command2_Click()
    End Sub

    Private Sub Command3_Click()
    End Sub

    "SHDocVw.InternetExplorer" is an Interface, not Class, so that paulgrunner's code would work well in a computer with VB6 installed, but might not work properly in a computer without VB6. But Internet.Application is a Class.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    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…
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    729 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

    21 Experts available now in Live!

    Get 1:1 Help Now