Solved

Automation Error in recursive function

Posted on 2001-07-02
8
365 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
  • 3
  • 3
  • 2
8 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 50 total points
Comment Utility
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
Comment Utility
Doh!  Thanks.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
Comment Utility
if a try to inspect this:
htmlDoc.frames.item(i).Document
i can see error "Access denied", someone of you know why.
0
 
LVL 28

Expert Comment

by:AzraSound
Comment Utility
Is this true for every framed page you visit or just certain ones?
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:vt45
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now