Solved

Automation Error in recursive function

Posted on 2001-07-02
8
375 Views
Last Modified: 2007-12-19
<----------Begin Code----->

Public Function GetHTMLElements(ByVal htmlDoc As Object, ByRef ResultCol As Collection, Optional sElementTagName As String, Optional sElementAttribute As String, Optional sElementAttributeName As String) As Boolean
Dim oElement As HTMLHtmlElement
Dim i As Integer
If ResultCol Is Nothing Then Set ResultCol = New Collection

If sElementTagName <> "" Then
    If sElementAttribute <> "" Then
        For Each oElement In htmlDoc.getElementsByTagName(sElementTagName)
            If UCase(oElement.Attributes(sElementAttribute)) = UCase(sElementAttributeName) Then
                ResultCol.Add oElement
            End If
        Next oElement
    Else
        For Each oElement In htmlDoc.getElementsByTagName(sElementTagName)
            ResultCol.Add oElement
        Next oElement
    End If
Else
    For Each oElement In htmlDoc.All
        ResultCol.Add oElement
    Next oElement
End If

If htmlDoc.frames.length > 0 Then
    For i = 0 To htmlDoc.frames.length - 1
        ***GetHTMLElements htmlDoc.frames(i).Document, ResultCol, sElementTagName, sElementAttribute, sElementAttributeName
    Next i
End If
If ResultCol.Count > 0 Then
    GetHTMLElements = True
Else
    GetHTMLElements = False
End If

End Function

<------------End Code------->

*** I get this error on the recursive call: "Method 'frames' of object 'DispHTMLDocument' failed"

I'm passing in and object like this:
Dim IEobj as SHDocVw.InternetExplorer

GetHtmlElements(IEobj.Document, ...)

The error occurs on the first recursion call.  Does anyone have an idea why this could be happening?  Thanks.
0
Comment
Question by:vt45
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 50 total points
ID: 6244877
i've seen problems before where people could not reference the document object directly from the frames collection, but could via its item property.  so try:
htmlDoc.frames.item(i).Document
0
 

Author Comment

by:vt45
ID: 6244944
Doh!  Thanks.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6861402
if a try to inspect this:
htmlDoc.frames.item(i).Document
i can see error "Access denied", someone of you know why.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Expert Comment

by:AzraSound
ID: 6874817
Is this true for every framed page you visit or just certain ones?
0
 

Author Comment

by:vt45
ID: 6876722
I've noticed that before too Richie.  It always seemed to be the "utility" frame the website designers set aside to store thier own information.  I guess they can make it inaccessable, but I'm not sure how.  In my case it was always the first frame in the loop, so instead of "For i = 0 To htmlDoc.frames.length - 1", i did "For i = 1 To htmlDoc.frames.length - 1".
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6877320
For every, that's it!
vt45, i did in same way (-1)!
Every frame is reached but for most properties, they have "Access denied".
I did a try with samples pages created by myself just to do a test, i mean, a page with frameset stuff and two more html with some stupid things inside.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6877569
You get access denied regardless of how you try and use it?  e.g.,


Set htmlDoc = htmlDoc.frames.item(i).Document

or just showing any property like the documentElement.innertext
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6877789
Set htmlDoc = htmlDoc.frames.item(i).Document

I got that error when try to access Document property/object and if i try to inspect some properties in Inspection window.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question