Solved

Automation Error in recursive function

Posted on 2001-07-02
8
372 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Zip Folders Using Chilkat Routines 1 58
Automatic Email Reminder 4 57
which modules are active in VB6 project? 6 41
VBA: Insert New column with specific format type 12 38
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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

856 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