vba to refresh ie page not working

dantheman9

Board Regular
Joined
Feb 5, 2011
Messages
175
Hi im using the following code to open a local html page as follows;

Code:
OpenBrowser WebPageDirectory
 
Function OpenBrowser(tmpURL)
Dim Browser As Object
Set Browser = CreateObject("InternetExplorer.Application")
If Browser.Addressbar = True Then
Browser.Addressbar = False
End If
If Browser.StatusBar = True Then
Browser.StatusBar = False
End If
Browser.Toolbar = False
If Browser.MenuBar = True Then
Browser.MenuBar = False
End If
Browser.Resizable = True
Browser.Visible = True
Browser.Navigate (tmpURL)
End Function

that is all ok ie opens the right page.
the issue i have is that this page needs to be refreshed, after intervals (i use the vba on time for this bit). but if i move the ie window around- like on to another mointor or even on the same screen, or if i open a new program and leave excel running then it seems to 'forget' or not be able to id the ie window to refresh.

the code im currently using to refresh is as follows;

Code:
For rresults = 0 To internetpage.count - 1
my_url = internetpage(rresults).Document.Title
If my_url Like "mypage" Then
internetpage(rresults).refresh
Exit For
End If
Next rresults

anyone some ideas on this?
i did try giving the ie window a public object ID, but it seems windows7 doesn't like that method.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Here’s what I tried.


  • Made Bowser static
  • Made OpenBrowser do a refresh if tmpURL = “”

I did a little testing and did not see a lack of refresh

Windows 7, two monitors, Excel 2000

By the way, I also tried

“Public Brower As Object”

I hadn’t seen a “Blue screen of death” in a logn time

HTML:
‘---------------------------------
  Option Explicit
  ‘---------------------------------
  Function OpenBrowser(tmpURL)
      Static Browser As Object
      If tmpURL <> "" Then
          Set Browser = CreateObject("InternetExplorer.Application")
          If Browser.Addressbar = True Then
              Browser.Addressbar = False
          End If
          If Browser.StatusBar = True Then
              Browser.StatusBar = False
          End If
              Browser.Toolbar = False
          If Browser.MenuBar = True Then
              Browser.MenuBar = False
          End If
          Browser.Resizable = True
          Browser.Visible = True
          Browser.Navigate (tmpURL)
      Else
          Browser.Refresh
      End If
  End Function
  ‘---------------------------------
  Sub test()
      OpenBrowser "my.yahoo.com"    
  End Sub
  ‘---------------------------------
  Sub testref()
      Dim i As Integer
      For i = 1 To 50
          OpenBrowser ""
          Application.Wait (Now + TimeValue("0:00:10"))
      Next i
      MsgBox "Ta Da"
  End Sub 
  ‘---------------------------------
 
Upvote 0
tlowry,

thanks for having a look at this!

I'll have a look at your work a see how it runs...i did try running the refresh with that sort of meothd first (but directly in the Sub rather than as a function)

I had to put something in in place as a quick fix for this yesterday as i need it running for the day - A rough solution i used was to run a modeless Userform with a webbrowser control in..seemed to do the trick, but had its limits (not resizable to fit on the second mointor etc but still did the trick sort of).

Today before seeing your post i did a bit of a searh to see that Chip Pearson has a method to give control over userforms which is great. then all i would need to do would be to find a way to resize the webcontrol in the userform to fill the empty space.

i'll let you know what i come up with!!

Cheers

Dan
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,703
Members
452,938
Latest member
babeneker

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top