3

I have been trying to figure out a way to refresh internest explorer through VBA. I have a webpage I need to refresh periodicly and I need VBA or something to refresh it. Do you guys know of a way to get VBA to refresh a webpage?

Hazior
  • 696
  • 4
  • 10
  • 26

1 Answers1

2

To use this code which applies Early Binding you will need to add a reference to "Microsoft Internet Controls" in the Visual Basic Editor

This code will open IE, go to google, wait for the page to load completely, then refresh.

Sub RefreshPage()

  Dim page As New InternetExplorer      
  page.Navigate "www.google.com"
  page.Visible = True      
  Do
  Loop Until page.ReadyState = READYSTATE_COMPLETE
  page.Refresh

End Sub
brettdj
  • 54,857
  • 16
  • 114
  • 177
Justin Self
  • 6,137
  • 3
  • 33
  • 48
  • This is fine if the OP wants to create a new instance but we are yet to hear if this is the case. Also, suggest you separate the `Dim page As New InternetExplorer` into two lines – brettdj Dec 31 '11 at 01:00
  • @brettdj: Why do you suggest seperating "Dim page as New InternetExplorer" onto two lines? – waqasahmed Jan 06 '12 at 11:40
  • option infer on and then use = new instead of as new. as new is very strange. It creates a new instance when you use it. Which is pretty unpredictable. – user4951 Mar 22 '17 at 17:44