Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forcing page refresh from VB

Status
Not open for further replies.

mwingeier

MIS
Jul 19, 2002
41
US
I have several pages that I use at work that could really benefit from an auto refresh. Unforntunately, the powers that be have decided that it is not in their best interest to just reprogram the page, they think the massive influx of traffic may crash the servers. Officially, IT tells me this can't be done, but I have a feeling that it can. Now I have used VB in the past, and I am familiar with it, but it has been a long time since I have really dug into it. The question is, can I run a VB program to look for the title of the web page window and force it to refresh at a given interval?
 
No idea how you'd do it in VB (I can't find IE in the list of available libraries in VB6), but this application looks like it will do the job for you:


Enjoy telling your IT department they're wrong! :)

Ed Metcalfe.

Please do not feed the trolls.....
 
I previously demonstrated how to use the Shell's explorer windows as file and folder browsers. Those core ideas there can be reworked and significantly simplified to produce a solution for this. For the example (which illustrates how to do this, but is not a complete solution) you'll need a form with a command button. Also add the following two references to your project:

o Microsoft Internet Controls
o Microsoft Shell Controls and Automation

Then drop in this code (which, as it stands, will refresh this very page whenever you click the button)
Code:
[blue]Option Explicit

Private Sub Command1_Click()
    Dim myShell As Shell
    Dim myWindow As Object ' Different objects can be returned. We don't know which one ahead of time
    
    Set myShell = New Shell
    ' Seek the IE window we are looking for amongst all the shell windows
    For Each myWindow In myShell.Windows
        ' One way of IDing an IE window
        'If TypeName(myWindow.Document) = "HTMLDocument" Then
        ' or, if you know the browser window title ...
        If myWindow.LocationName = "Visual Basic(Microsoft): Version 5 & 6 - Forcing page refresh from VB" Then
            myWindow.Refresh2
        End If
    Next
End Sub[/blue]


 
It was to ME. I sent myself a copy to keep for reference for the next time I want to do that. It's faster and more accurate to search my email folder than to search a TT forum.

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
Yes, I started out with that and it worked very well. I wanted to get rid of the form, however, which meant a well overdue dive into Java for me. Then I came across a small freeware scripting language similar to WSH, which looks like it will fit the bill with all due ease and simplicity. Thank you for your pointers.
 
VB apps don't need to have forms, you know ... still, as long as you've got a solution.
 
In the back of my mind, I knew I didn't need forms in a VB program, but I suddenly was at a loss as to how to get rid of them. Moment of absent-mindedness. Still, this freeware gig called Auto Hotkey is pretty slick for small jobs,
 
I have a problem related to this one. So i have a webbrowser in my vb and I am refreshing a page and readind the document.title but I don't need to refresh the whole page - it takes massive influx of traffic and resources on my computer because I am refreshing that page every 3 seconds, I only need the title of that page. When the title changes I need to fire up something else. Any idea ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top