Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

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

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

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)

1 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:    
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 ("http://www.experts-exchange.com")
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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