Dick,
That's great, just what I need.
I had to make a minor change, substitute the "MyFile.htm"
with "MyTitle". Also to ensure the .htm file actually has
a title like:
<TITLEMyTitle</TITLE
Without a title the filename appears in the IE window, but
the code errors when it trys to return .Document.Title
From the SHDocVw object browser I found I can also use
If InStr(1, SWs(i).LocationURL, "MyFile.htm") 0 Then
In my last post I knew I had missed something obvious in
x = Shell("Iexplore.exe C:\Temp\MyFile.htm", 1)
however this seems to work
x = Shell("Explorer C:\Temp\MyFile.htm", 1)
but strangely not "Internet Explorer" as suggested in some
places in this ng, at least not for me.
I've also found the odd hint in this ng that IE can be
automated, might look into this a bit more (for curiosity,
your code already does what I need).
Many thanks for your help,
Sandy
savituk yahoo co uk
-----Original Message-----
Sandy
Set a reference (Tools - References) to Microsoft
Internet Controls. Then
this should work:
Sub Refreshbrowser()
Dim i As Long
Dim SWs As New SHDocVw.ShellWindows
For i = 0 To SWs.Count - 1
If InStr(1, SWs(i).Document.Title, "MyFile.htm") 0
Then
SWs(i).Refresh
Exit For
End If
Next i
End Sub
--
Dick Kusleika
MVP - Excel
Excel Blog - Daily Dose of Excel
www.dicks-blog.com
"Sandy V" wrote in
message
...
Thanks Bob,
I had thought that but the trouble is I want to fire it
from a button on the sheet (refresh IE). I think would
need to somehow find the relevant window, activate it
and
then SendKeys as you suggest.
Another possibility might be to start IE within vba and
load it with "Path\Myfile.html". I guess this would
mean
using Shell although for some reason I can't even get
this to work:
x = Shell("Iexplore.exe C:\Temp\MyFile.htm", 1)
'error 53, File not found (even if I include path to
IE, path\filename are correct)
Assuming I've just missed something obvious in the
above, I don't know thereafter if it's possible to set
reference to it and the next step to refresh it.
Regards,
Sandy