Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Retain focus of IE using DocumentComplete

I have a macro that looks at a number of URL's and extracts certain data from
it to various worksheets.

I can get the class module to use WithEvents IE As InternetExplorer, then
navigate to the desired webpage but if i try to change from one worksheet to
another within the class module, i get an error. (I assumed this was due to
withevent).

When i tried running that code in a standard module, after the
IE_Documentcomplete event had fired twice, when it got to a line Set
oResultPage = IE.Document then it no longer knew what IE refferred to - so
i'm basically trying to get a webpage (created using Set IE = New
InternetExplorer from the class module) to be recognised in the main module
for a macro to read the HTML data. The extraction code for that works fine,
but how do i keep the "focus"? I altered the code as the readystate was too
unreliable.

This is what i have in the class module

Option Explicit

Private WithEvents IE As InternetExplorer

Private Sub Class_Initialize()
On Error Resume Next
IE.Visible = True
If Err.Number < 0 Then
Set IE = New InternetExplorer
IE.Visible = False
End If
End Sub

Public Sub Navigate(ByVal URL As String)
IE.Navigate URL
End Sub

Private Sub IE_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim xcount As Integer
If TypeName(pDisp) < Empty Then
gj = gj + 1
End If
If gj = 2 Then
InUse = False
End If
End Sub

So basically, from the original macro that navigated to the URL using the
class navigate, I am trying to get

For Each r In Range("A1:C60")
Do
DoEvents
Application.Wait Now() + (TimeValue("00:00:01"))
Loop Until InUse = False

If gj = 2 Then
gj = Empty
Call ExtractData
End If

when gj=2 (the DocumentComplete event has fired twice), then i want the
ExtractData macro to be able to see the webpage that the class module code
just created.

I've probably made a total mess of explaining that, but i'm going braindead
right now.
Hope someone can help with this.
George

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Retain focus of IE using DocumentComplete

Yup - jsut me being silly again.

Set myIE = IE

in the class module and have it set as a public variable in the main macro.

doh!!
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
Retain Column Width Box666 Excel Discussion (Misc queries) 1 October 7th 08 11:18 AM
De-dup and retain new records only jaltsman Excel Worksheet Functions 0 June 13th 08 03:11 AM
retain result RobcPettit[_2_] Excel Programming 1 September 17th 06 01:13 PM
Formula should retain T De Villiers[_29_] Excel Programming 7 July 6th 06 02:21 PM
How to retain collection in function? durex[_12_] Excel Programming 0 December 1st 05 12:41 AM


All times are GMT +1. The time now is 05:25 PM.

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

About Us

"It's about Microsoft Excel"