Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Refresh / Update URL

Andrew,
Sounds like Automating IE would be better:
http://www.microsoft.com/mind/0898/dom.asp
http://www.mvps.org/access/modules/mdl0062.htm

NickHK

"Andrew" wrote in message
...
Hi,

With help from this site I am able to open a url based on code but now I
want to update the same window (ie not open another windows) of IE. How

do I
do that?


Sub xx()
ThisWorkbook.FollowHyperlink _
Address:="http://finance.yahoo.com/"
Cancel = True
End Sub

Now I want to go to http://help.yahoo.com/help/fin/

I know I could go to the second page in one step but this is just getting
the basics for some more complex coding after I get the basics.
--
Andrew



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 358
Default Refresh / Update URL

Hi NickHK,

I've has a look at both of those sites and the are a bit techo for me. I've
copied the code into Access (I'd prefer Excel) and I'm having trouble with
the CDialog beeing defined.

Can we cut the code down so it basically can open a new web browser the
first time and waits 10 seconds and the changes the URL in the browser to
another.

eg 1st www.google.com
2nd www.Yahoo.com


Here's the code

Private Sub Command0_Click()
On Error GoTo ErrHandler
Dim objShellWins As SHDocVw.ShellWindows
Dim objIE As SHDocVw.InternetExplorer
Dim objDoc As Object
Dim i As Integer
Dim strOut As String
Dim intFree As Integer
Dim clsDialog As Cdialog ' Wrapper around GetOpen/SaveFileName
Const URL_TO_SEARCH = "http://www.mvps.org/access"
Const ANCHOR_DESC_TO_SEARCH = "Comprehensive Links"

' Instantiate
Set objShellWins = New SHDocVw.ShellWindows
' There might be multiple IE windows open
For Each objIE In objShellWins
With objIE
' Try to locate the browser with a specific address
' in it's AddressBar. You can also Navigate to a new
' address
If (InStr(1, _
.LocationURL, _
URL_TO_SEARCH, vbTextCompare)) Then

' Get a reference to the HTMLDocument contained within
' the InternetExplorer instance
Set objDoc = .Document
If (TypeOf objDoc Is HTMLDocument) Then
' Limitations of running the following command:
' Call objIE.ExecWB( _
OLECMDID_SAVEAS, _
OLECMDEXECOPT_PROMPTUSER)
' IE's "SaveAs" dialog doesn't allow you to
' retrieve the filename the user typed in
' so use our own code for the SaveAs dialog
' The CDialog class is simply a wrapper around
' the code listed at the following URL
' http://www.mvps.org/access/api/api0001.htm
'
Set clsDialog = New Cdialog
With clsDialog
.Hwnd = hWndAccessApp
.StartDir = CurDir
.ModeOpen = False
.DefaultExtension = "htm"
.Title = "Please select a folder to save the file"
.Filter = "HTML Files (*.htm, *.html)|*.htm"
strOut = .Action
End With
If Len(strOut) Then
' Now that we have a filename,
' Save out the HTML as a persisted file
intFree = FreeFile
Open strOut For Output As #intFree
Write #intFree, objDoc.body.parentElement.innerHTML
Close #intFree
' Alternatively, you could also just
' inpect the HTM at runtime via the property
With objDoc.all
For i = 1 To .Length
If (TypeOf .Item(i) Is HTMLAnchorElement) Then
If .Item(i).nodeName = "A" Then
' Only look for a link which has the
description
' "Comprehensive Links" attached to it
If (InStr(1, _
.Item(i).innerText, _
ANCHOR_DESC_TO_SEARCH, _
vbTextCompare)) Then
' Print out the URL
Debug.Print
objDoc.all.Item(i).href
' Bail out
Exit For
End If
End If
End If
Next
End With
End If
End If
Exit For
End If
End With
Next

ExitHe
On Error Resume Next
Close #intFree
Set clsDialog = Nothing
Set objDoc = Nothing
Set objIE = Nothing
Set objShellWins = Nothing
Exit Sub
ErrHandler:
With Err
MsgBox "Error: " & .Number & vbCrLf & .Description, _
vbCritical Or vbOKOnly, .Source
End With
Resume ExitHere
End Sub




Thanks.


--
Andrew


"NickHK" wrote:

Andrew,
Sounds like Automating IE would be better:
http://www.microsoft.com/mind/0898/dom.asp
http://www.mvps.org/access/modules/mdl0062.htm

NickHK

"Andrew" wrote in message
...
Hi,

With help from this site I am able to open a url based on code but now I
want to update the same window (ie not open another windows) of IE. How

do I
do that?


Sub xx()
ThisWorkbook.FollowHyperlink _
Address:="http://finance.yahoo.com/"
Cancel = True
End Sub

Now I want to go to http://help.yahoo.com/help/fin/

I know I could go to the second page in one step but this is just getting
the basics for some more complex coding after I get the basics.
--
Andrew




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Refresh / Update URL

You don't need all that CDialog stuff do you.
can't you just
Call UpDateIE ("www.google.com")
Call UpDateIE ("www.Yahoo.com")

Private function UpdateIE(argURL as string)
'Assumes you created a valid objIE object
objIE.Netvigate2 argURL
do until objIE.ReadyState = READYSTATE_COMPLETE
'waiting for the web page to finish loading
loop

end function

Or you can the "MS Web Browser Control" on a userform or indeed on your
worksheet.
That way you contain it all in your WB.

NickHK

"Andrew" wrote in message
...
Hi NickHK,

I've has a look at both of those sites and the are a bit techo for me.

I've
copied the code into Access (I'd prefer Excel) and I'm having trouble with
the CDialog beeing defined.

Can we cut the code down so it basically can open a new web browser the
first time and waits 10 seconds and the changes the URL in the browser to
another.

eg 1st www.google.com
2nd www.Yahoo.com


Here's the code

Private Sub Command0_Click()
On Error GoTo ErrHandler
Dim objShellWins As SHDocVw.ShellWindows
Dim objIE As SHDocVw.InternetExplorer
Dim objDoc As Object
Dim i As Integer
Dim strOut As String
Dim intFree As Integer
Dim clsDialog As Cdialog ' Wrapper around GetOpen/SaveFileName
Const URL_TO_SEARCH = "http://www.mvps.org/access"
Const ANCHOR_DESC_TO_SEARCH = "Comprehensive Links"

' Instantiate
Set objShellWins = New SHDocVw.ShellWindows
' There might be multiple IE windows open
For Each objIE In objShellWins
With objIE
' Try to locate the browser with a specific address
' in it's AddressBar. You can also Navigate to a new
' address
If (InStr(1, _
.LocationURL, _
URL_TO_SEARCH, vbTextCompare)) Then

' Get a reference to the HTMLDocument contained within
' the InternetExplorer instance
Set objDoc = .Document
If (TypeOf objDoc Is HTMLDocument) Then
' Limitations of running the following command:
' Call objIE.ExecWB( _
OLECMDID_SAVEAS, _
OLECMDEXECOPT_PROMPTUSER)
' IE's "SaveAs" dialog doesn't allow you to
' retrieve the filename the user typed in
' so use our own code for the SaveAs dialog
' The CDialog class is simply a wrapper around
' the code listed at the following URL
' http://www.mvps.org/access/api/api0001.htm
'
Set clsDialog = New Cdialog
With clsDialog
.Hwnd = hWndAccessApp
.StartDir = CurDir
.ModeOpen = False
.DefaultExtension = "htm"
.Title = "Please select a folder to save the file"
.Filter = "HTML Files (*.htm, *.html)|*.htm"
strOut = .Action
End With
If Len(strOut) Then
' Now that we have a filename,
' Save out the HTML as a persisted file
intFree = FreeFile
Open strOut For Output As #intFree
Write #intFree,

objDoc.body.parentElement.innerHTML
Close #intFree
' Alternatively, you could also just
' inpect the HTM at runtime via the property
With objDoc.all
For i = 1 To .Length
If (TypeOf .Item(i) Is HTMLAnchorElement)

Then
If .Item(i).nodeName = "A" Then
' Only look for a link which has

the
description
' "Comprehensive Links" attached

to it
If (InStr(1, _
.Item(i).innerText, _
ANCHOR_DESC_TO_SEARCH, _
vbTextCompare)) Then
' Print out the URL
Debug.Print
objDoc.all.Item(i).href
' Bail out
Exit For
End If
End If
End If
Next
End With
End If
End If
Exit For
End If
End With
Next

ExitHe
On Error Resume Next
Close #intFree
Set clsDialog = Nothing
Set objDoc = Nothing
Set objIE = Nothing
Set objShellWins = Nothing
Exit Sub
ErrHandler:
With Err
MsgBox "Error: " & .Number & vbCrLf & .Description, _
vbCritical Or vbOKOnly, .Source
End With
Resume ExitHere
End Sub




Thanks.


--
Andrew


"NickHK" wrote:

Andrew,
Sounds like Automating IE would be better:
http://www.microsoft.com/mind/0898/dom.asp
http://www.mvps.org/access/modules/mdl0062.htm

NickHK

"Andrew" wrote in message
...
Hi,

With help from this site I am able to open a url based on code but now

I
want to update the same window (ie not open another windows) of IE.

How
do I
do that?


Sub xx()
ThisWorkbook.FollowHyperlink _
Address:="http://finance.yahoo.com/"
Cancel = True
End Sub

Now I want to go to http://help.yahoo.com/help/fin/

I know I could go to the second page in one step but this is just

getting
the basics for some more complex coding after I get the basics.
--
Andrew






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update querytable connections and refresh data Dale Fye Excel Discussion (Misc queries) 0 November 2nd 07 03:46 PM
Update querytable connections and refresh data Dale Fye Charts and Charting in Excel 0 November 2nd 07 03:46 PM
Inability to start Excel after Refresh update kdixon7244 Excel Discussion (Misc queries) 1 September 29th 06 10:30 PM
Date in cell to update upon Pivot Table refresh chris46521[_33_] Excel Programming 4 August 17th 06 11:02 PM
Update cell's value without refresh screen? lantiger Excel Programming 0 May 26th 04 05:23 PM


All times are GMT +1. The time now is 11:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"