ipf.value question

R

ron

I need to select a timezone on a webpage. In the past, the code for
that page had something like
<select name="timezone">
<option value="Eastern">
<option value="Central">
and so on. The following commands worked fine in my macro to select
the desired timezone on the webpage
Set ipf = ie.document.all.Item("timezone")
ipf.Value = "Eastern"

Now the code behind the webpage has been updated and the timezone code
reads as follows
<select name="timezone">
<option selected>Eastern
<option>Central
<option>Mountain
<option>Pacific

The "ipf.value" command no longer selects the correct timezone. Any
thoughts on how to accomplish this selection with the new webpage
code?..Thanks in advance, Ron
 
B

Bob Phillips

This is an excel group.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
R

ron

That's why I'm posting here. I use "set ipf" and "ipf.value" in many
of my Excel macros. They have been discussed in this newsgroup in the
past...Ron
 
T

Tim Williams

Ron,

You'll need to loop through the options, find the one with .text = "Eastern"
and set the selectedIndex of the list to the index of that option (they
start at 0)

something like (untested)


Function SetSelect(s,val) as boolean
dim x as integer
dim r as boolean

r=false
for x=0 to s.options.length-1
if s.options(x).text = val then
s.selectedIndex=x
r=true
exit for
end if
next x

SetSelect=r

end function


usage:
if not SetSelect(ipf,"Eastern") then
'something went wrong
else
'continue...
end if


Tim.
 
R

ron

Thanks Tim for the example and explanation! It got me back up and
running...Many thanks, Ron
 

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

Top