Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE automation query

Status
Not open for further replies.

robcarr

Programmer
May 15, 2002
633
GB
Hi,

I have the following lines within a module to create a record on a website i use.

Code:
Application.Wait Now() + TimeValue("00:00:01")
    .Document.forms("savereq").elements("df_49").selectedindex = 26 ' account code

i have a problem whereby the powers that be change the "selectedindex" location, i was wondering if i could find the exact item location by name(this never changes) instead of index and then get the system to accept the name.

any thoughts ideas

Hope this is of use, Rob.[yoda]
 



Hi,

What is the referenced object and what object library?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
it is a dropdown/combobox on a website.

they use the Microsoft Internet Controls and the Microsoft HTML Object Library

Hope this is of use, Rob.[yoda]
 


It might be helpful to see the code for the refereced object.
Code:
[b][i]SomeObject[/i][/b].Document.forms("savereq").elements("df_49").selectedindex = 26 '
and the code that created or instantiated this object.

I'm fishing, not knowing nearly anything about HTML Objects. Hopefully someone with some experience will jump in.


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
object is

Code:
Dim objie As SHDocVw.InternetExplorer

  Set objie = GetOpenIEByTitle(myPageTitle, False)

digging around it seems it might be possible to do it with code to loop through the combobox using the findstring list until it finds a match and then get the index number from the match and use that index number to populate the combobox.

Not sure how to get the loop to work.

Hope this is of use, Rob.[yoda]
 


There is no SHDocVw object in the HTML object library.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I will wait and see what other responses I get, as the coding works and creates the record and does everything without any errors.

I just want to tweak to improve the combobox.

Hope this is of use, Rob.[yoda]
 

OK I found ShDocVw.dll in the System32 folder. You should SEE that reference in your list!

Here's what it appears to me.

1. Your reference object that I was asking about is NOT a combobox. It is an Internet Page (Document)

2. The Combobox is probably the Element df_49 on form savereq

3. Your line of code seems to be displaying item 26 in the source list for the combobox.

So...

On Document myPageTitle
On Form savereq
In Combobox df_49
Dsiplay the 26th item

That's my guess. So if I am correct, ItemIndex does not identify a combobox. Rather .Elements(SomeName) does.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I want to be able to enter aa text string instead of the index number, as the index number changes all the time.

everytime i enter the text string as it is in the index, it displays a blank combobox.

Hope this is of use, Rob.[yoda]
 




It seems to me that the Index is not selecting a combbox, but rather an item IN the combobox.

So if you want to select a different item, based on a string value, loop thru the control until you encounter THAT value.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
So if you want to select a different item, based on a string value, loop thru the control until you encounter THAT value.

that is what i want to do, but i dont know how to get it to work

Hope this is of use, Rob.[yoda]
 


Neither do I, but if I were sitting at your system, I would STEP into the code you currently have and use faq707-4594 and discover what properties I need to manupulate to get what I am looking for.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I have done this now and here is the code to loop through the HTML index and match the value to the required value and then populate the index.

Code:
 For Each Tag In objie.Document.forms("savereq").elements("DF_21") ' Vendor Class
Debug.Print Tag.innerText
If Tag.innerText = Range("g11").Value Then
DropID = Tag.Value
Set Ipf = objie.Document.forms("savereq").elements("DF_21")
Ipf.Value = DropID

Application.Wait Now() + TimeValue("00:00:01")
    
Exit For
End If
Next Tag

Regards

Rob.

Hope this is of use, Rob.[yoda]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top