From: Nobody on 14 Jun 2010 00:50 "Norm" <NormF4(a)Spoof.com> wrote in message news:hv4a89$2n4$1(a)news.eternal-september.org... > I am having a problem understanding how this works. I assume to use the > click button method I could use If obj.Name = "btnSignon" Then obj.click, > but if I put that in the loop with entering the other information, the > button does not get clicked, as the web page does not show the infomation > until the Document_Complete has finished. It seems that once the > Document_Complete has finished the Explorer object is released and I > cannot use it in the Timer code. > > So I guess my question is where do I put the click button code to get it > to work. I did something similar with paypal, but I used DOM and the Form element has "Submit" method that you can use. There is more than one way to get to the form. Here is one way(Air code): Dim WithEvents ie As InternetExplorer Private Sub Test() Dim oHTML As IHTMLDocument2 Dim oHTMLfrm As MSHTML.IHTMLFormElement 'Dim oElement As MSHTML.IHTMLInputElement Dim oElement As MSHTML.IHTMLElement Set oHTML = ie.Document For Each oHTMLfrm In oHTML.Forms Debug.Print "'"; oHTMLfrm.Name; "'" If oHTMLfrm.Name = "signon" Then For Each oElement In oHTMLfrm.elements Debug.Print "oElement.innerHTML: '"; oElement.innerHTML; "'" Debug.Print "oElement = "; oElement.Name Select Case oElement.Name Case "userid": oElement.Value = "myid" Case "password": oElement.Value = "mypass" End Select Next oHTMLfrm.submit End If Next ExitSub: Set oBody = Nothing Set oHTMLfrm = Nothing Set oHTML = Nothing End Sub
From: Mayayana on 14 Jun 2010 09:10 | I am having a problem understanding how this works. I assume to use the | click button method I could use If obj.Name = "btnSignon" Then | obj.click, but if I put that in the loop with entering the other | information, the button does not get clicked, as the web page does not | show the infomation until the Document_Complete has finished. It seems | that once the Document_Complete has finished the Explorer object is | released and I cannot use it in the Timer code. | | So I guess my question is where do I put the click button code to get | it to work. | You might be able to use Nobody's method, but that will require that the button be in a FORM, which is not necessarily the case. To hold onto the Document just set a global variable in Document_Complete. To be on the safe side you might also want to check that it's avaialable: Private Doc as mshtml.HTMLDocument Private Sub Explorer_DocumentComplete(ByVal pDisp As Object, URL As Variant) Set Doc = Nothing If Not Explorer.Document Is Nothing then Set Doc = Explorer.Document End Sub In BeforeNavigate set Doc = Nothing. That way you always have the current Document, if you have any at all. It won't matter if you refresh or navigate elsewhere. Doc is always your current Document. You can do the click after your loop. You can still get hold of the button object in the loop. Or if you know the ID I think you can also use Doc.all("btnSignon").click
From: Larry Serflaten on 14 Jun 2010 09:44 "Norm" <NormF4(a)Spoof.com> wrote > So I guess my question is where do I put the click button code to get > it to work. You could grab the document as mayayana suggests or you could just hold on to the button for the timer event: ' At the top > >> Option Explicit > >> Private WithEvents Explorer As InternetExplorer Private Button As Object ' In Document_Complete > >> For Each obj In Explorer.Document.All() > >> If obj.Type = "text" And obj.Name = "userid" Then obj.Value = "*********" > >> If obj.Name = "password" Then obj.Value = "*********" > >> If obj.Name = "destination" Then obj.Value = "AccountSummary" If obj.Name = "btnSubmit" Then Set Button = obj > >> Next ' In Timer event > >> Me.Timer1.Enabled = False Button.Click > >> Unload Me I don't know what the name of your button is, I used "btnSubmit" but you would have to use the actual name.... Good Luck! LFS
From: Norm on 14 Jun 2010 11:11 Thanks very much for all the information. I am still working on understanding all of it. :-Z For some reason Larry your suggestion did not work, I would have thought it would, but the page would open, enter the information, but never click the button. When I tried to do Debug.Print Button.Name I got a message that the object did not support that method. So I may not have been getting the object set correctly. Anyway Mayayana's method did work, so I will use it for now, but in my usual stubborn way I will keep playing around with it in the hope that I will eventually understand some of it anyway. Thanks again, Norm
First
|
Prev
|
Pages: 1 2 Prev: Arranging windows of an external application Next: Handling DPI changes in my vb6 app |