PDA

View Full Version : handle to IE to populate data



akanchu
02-01-2008, 07:56 PM
This is my first and hope I do not make it too complex.
I want to automate a process using an excel macro. I manually fill in fields of a webpage. most of the fields are static, so I want to create a macro that could fill the values for me automatically.

There multiple pages involved here.
The first page has a link reading "Create Request". On clicking this link, it opens up a new IE window with all the fields empty and these fields need to be populated by data in VBA code variables.


I achieved the process of opening this form by using the document object. Code synopsis of VBA is as follows:


IEhandle2.Navigate URL2
Set IEdoc1 = IEhandle2.Document


For i = 1 To IEdoc1.links.Length
If Trim(IEdoc1.links(i - 1).innertext) = "Create Request" Then
IEdoc1.links(i - 1).Click
End If
Next i


But once the new webpage opens, I lose handle to that new page. And since I have lost access to the new window, cannot get access to the fields that I want to populate.
My questions are :
(a) How can I get a handle to the new window that came up after I performed the click. Note, I cannot use the new page address directly as a part of Navigate2 function, because few contents of the resultant webpage vary for both cases:banghead: .


(b) I tried the Navigate2 option to just to see the fields of the webpage that I want to populate.
The problem is that even though there are many text fields on the webpage, none of them listed when I tried the following command :
Debug.Print i, Mid(IEdoc3.links(i - 1).innertext, 1, 20), TypeName(IEdoc3.links(i - 1)), IEdoc3.links(i - 1).innerHTML
It gave me all the buttons, drop downs, but no text fields.
Any suggestions, how could I get access to the text fields on the webpage, so that I can populate the values of VBA variables to the individual text boxes.


I cannot use anyother programming language to get this done. VBA only.
Any inputs would be helpful to proceed in getting this automation done.


Thanks