Solved

Automation Error in recursive function

Posted on 2001-07-02
8
370 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
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Concatenate 2 userform comboboxes to a userform text box 4 64
How to create a duplicate finder Application 9 121
VBA filters 2 62
Access 2013 combo box not working 3 45
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

821 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