PDA

View Full Version : Watch what a web page does in VBA



chacanger
02-18-2011, 02:39 PM
Hi

I have recently been automating a process in my work were I need to type values into a Web Page, the issue is that I have found SendKeys is very very unreliable, however to use it I must send key presses into it with F12 and Enter. The odd thing is that according to some info certian commands for example F12 actually come out as } and Enter as Space Bar. What I need to do is somehow watch what actually comes out on some of the other key presses...

Is there a way to see behind the scenes on the web page as it receives data going into it with Vba?

Thanks

Zack Barresse
02-20-2011, 10:35 AM
Hi there,

I think you may want to look back a little further at the actual process you're taking. SendKeys is, as you point out, highly unreliable. Could you perhaps post a little on the scope of your project?

chacanger
02-20-2011, 03:50 PM
Hi there,

I think you may want to look back a little further at the actual process you're taking. SendKeys is, as you point out, highly unreliable. Could you perhaps post a little on the scope of your project?

Thanks for the reply Zack

Basicaly I have to put information into a aspx page which has an Input box called "TEXTINPUT", what happens is that you have to type info into the"TEXTINPUT" box and press enter, once you press enter the info you type in "TEXTINPUT" box shows as an ordinary piece of text, were as the "TEXTINPUT" box moves down and changes what you can put into it, unlike normal forms the input box dosen't change name, only it's properties, the diagram below shows roughly how it works...

http://i860.photobucket.com/albums/ab168/chacanger/Misc/Exmple.jpg

As I want to automate the enter and F12 pressing. Accorinding to some information behind the scenes it actually puts in } for F12 and " " (Space) for enter, but It dosen't work when I try to put them into the boxes. Here is some example code of how it currently looks...

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub Auto()
Dim ie As InternetExplorer
Set ie = New InternetExplorer

ie.Navigate "The WebPage"

Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop

ie.Document.all("TEXTINPUT").Value = "Chacanger"
SendKeys "ENTER", True
Sleep 200
ie.Document.all("TEXTINPUT").Value = "Random Text"
SendKeys "ENTER", True
Sleep 200
ie.Document.all("TEXTINPUT").Value = "More Random Text"
SendKeys "ENTER", True
Sleep 200

ie.Document.all("TEXTINPUT").Value = "Another Random Text"
SendKeys "ENTER", True
Sleep 200
ie.Quit
Set ie = Nothing

End Sub

Thanks for any help.

Zack Barresse
02-20-2011, 04:01 PM
What is the website URL?

chacanger
02-20-2011, 04:46 PM
What is the website URL?

Thanks for the reply

Unfortunately I can't show you as it is on an internal intranet within my company rather than being on the web, however you can replicate something similar on www.Google.co.uk (http://www.Google.co.uk), and replacing "TEXTINPUT" with "q". The rule would be that you can't use the buttons to start a search as the page I'm trying to automate dosen't have buttons.

Thanks again