Run-Time Error 91 for Internet Explorer .elements(name).value

Discussion in 'Microsoft Excel Programming' started by chris_j_adams@hotmail.com, Oct 24, 2006.

  1. Guest

    Hi,

    Can anyone provide some advice as to why the line marked "ERROR" below
    results in a Run-time error 91?

    I know it relates to .elements(nm).Value. I've successfully tested to
    see if I can hard-code the name and debug.print the value. However it
    won't accept a built-up string (nm).

    Sub Test()

    Set IeApp = New InternetExplorer
    IeApp.Visible = True
    IeApp.Navigate "http://www.mywebsite.com"
    Do: Loop Until IeApp.ReadyState = READYSTATE_COMPLETE

    With IeApp.Document.forms("form")
    For Each cell In rng
    nm = "rates[" & cell & "]"
    cell.Offset(0, 1) = .elements(nm).Value <== ERROR
    Next cell
    End With

    End Sub

    Many thanks in advance if anyone can provide some advice.
    Regards,
    Chris Adams
     
    , Oct 24, 2006
    #1
    1. Advertisements

  2. Guest

    Btw, below is the HTML code that I'm trying to extract the value from.
    Basically, its a table with boxes populated by numbers, and I'm trying
    to get the numbers.

    <table class="layout">
    <tr>
    <td class="layout" valign="top">
    <table>
    <tr>
    <th>Ccy</th>
    <th>1 GBP =</th>
    </tr>
    <tr>
    <td>AED</td>
    <td><input type="text" class="rate"
    name="rates[AED]"
    value="6.8026" /></td> <==
    VALUE TO GET
    </tr>
     
    , Oct 24, 2006
    #2
    1. Advertisements

  3. Guest

    Btw, below is the HTML code that I'm trying to extract the value from.
    Basically, its a table with boxes populated by numbers, and I'm trying
    to get the numbers.

    <table class="layout">
    <tr>
    <td class="layout" valign="top">
    <table>
    <tr>
    <th>Ccy</th>
    <th>1 GBP =</th>
    </tr>
    <tr>
    <td>AED</td>
    <td><input type="text" class="rate"
    name="rates[AED]"
    value="6.8026" /></td> <==
    VALUE TO GET
    </tr>
     
    , Oct 24, 2006
    #3
  4. Guest

    For what its worth, I've fashioned a workaround, less elegant but its
    working so far. I loop through the table and push the values back to
    Excel. Here's the code.

    With IeApp.Document.forms("form")
    r = .elements.Length - 3
    For i = 1 To r
    ccy = Mid(.elements(i).Name, 7, 3)
    ccyVal = .elements(i).Value
    Set rngCCY = rng.Find(ccy)
    rngCCY.Offset(0, 1) = ccyVal
    Next i
    End With

    Thanks to those who took the time to check it out anyway.
    Regards,
    Chris Adams
     
    , Oct 24, 2006
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Piers Clinton-Tarestad

    Re: Run-time error '11' & Run-time error '1004'

    Piers Clinton-Tarestad, Jan 9, 2004, in forum: Microsoft Excel Programming
    Replies:
    0
    Views:
    389
    Piers Clinton-Tarestad
    Jan 9, 2004
  2. Piers Clinton-Tarestad

    Run-time error '11' & Run-time error '1004'

    Piers Clinton-Tarestad, Jan 9, 2004, in forum: Microsoft Excel Programming
    Replies:
    0
    Views:
    819
    Piers Clinton-Tarestad
    Jan 9, 2004
  3. Replies:
    2
    Views:
    1,521
  4. Rick Rothstein
    Replies:
    0
    Views:
    497
    Rick Rothstein
    Jul 27, 2009
  5. Lars-Åke Aspelin
    Replies:
    0
    Views:
    348
    Lars-Åke Aspelin
    Jul 27, 2009
Loading...

Share This Page