string variable in .elements( ).value doesn't work

C

chris_j_adams

Hi,

I'm trying to pull some values out of a table in IE using Excel 97.

This works:
IeApp.Document.forms("form").elements("rates[AUD]").Value

This doesn't:
nm = "rates[" & ccy & "]"
IeApp.Document.forms("form").elements(nm).Value

Can anyone shed any light on why it may not work please?
Btw, the code I'm trying to extract it from appears below.

Many thanks in advance for any advice/help.
Regards,
Chris Adams

<table class="layout">
<tr>
<td class="layout" valign="top">
<table>
<tr>
<th>Ccy</th>
<th>1 GBP =</th>
</tr>
<tr>
<td>AUD</td>
<td><input type="text" class="rate"
name="rates[AED]"
value="2.501" /></td> <==VALUE
I WANT
</tr>
 
B

Björn Langhof

This works:
IeApp.Document.forms("form").elements("rates[AUD]").Value

This doesn't:
nm = "rates[" & ccy & "]"
IeApp.Document.forms("form").elements(nm).Value

What about
nm = "rates[" + ccy + "]"

Björn
 
C

chris_j_adams

Björn,

Many thanks for your advice. I tried that but unfortunately it didn't
work either. For what its worth, I've fashioned a workaround, which
is 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


Many thanks again for your help, much appreciated.
Regards,
Chris Adams
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,206
Messages
2,571,069
Members
47,677
Latest member
MoisesKoeh

Latest Threads

Top