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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBscript for Internet Searches 2

Status
Not open for further replies.

DrMingle

Technical User
May 24, 2009
116
US
I use the same seven websites at my office everyday all day...

Would it make sense to create some VB script to handle the multiple pages and sites?

Can anyone put me in the right direction for some code?
 
Since IE7 you may have several startup pages ...
 
Unfortunately at my office we are not allowed to download IE7. In addition, the sites I am using have several pages to click through and forms to fill out to get the information that I need, so just having multiple pages open wouldn't be enough.

Rather than have the script pull the data for me...I simply want to tell the computer what seven websites I need it to go to and what buttons to click and forms to fill out and to leave the web pages open on my computer so that I can go view the data present and make determinations.

Is this possible?
 
Yes it is possible.

Navigating to a web site is rather easy.

Code:
Dim objIE
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = False
objIE.Navigate2 "[URL unfurl="true"]http://www.thespidersparlor.com"[/URL]
objIE.Visible = True

In order to autopopulate forms you will need to identify the form elements so you can set values for them.

Here is a sample I used to use to login to hotmail.
Code:
Set WshShell = CreateObject("WScript.Shell")
Set IE = CreateObject("InternetExplorer.Application")
IE.navigate2 "[URL unfurl="true"]http://www.hotmail.com"[/URL]
While IE.busy
	wscript.sleep 10
Wend
IE.Visible=True
WScript.Sleep 2000
WshShell.AppActivate "Sign In"
email =  "email@company.com"
WshShell.SendKeys email
WScript.Sleep 300
WshShell.SendKeys "{TAB}"
WScript.Sleep 300
WshShell.SendKeys "Password"
WScript.Sleep 300
WshShell.SendKeys "{Enter}"
Set IE = Nothing



I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Is it possible to have all seven sites open up in a new window...

Below is what I have so far...

Sub Search()

Dim objIE
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = False

'Revolutionhealth.com

objIE.Navigate2 "objIE.Visible = True

'Whitepages.com
objIE.Navigate2 "objIE.Visible = True

'WebMD.com
objIE.Navigate2 "objIE.Visible = True

'Medicare.gov
objIE.Navigate2 "objIE.Visible = True

'FSMB.org
objIE.Navigate2 "objIE.Visible = True

'Google.com
objIE.Navigate2 "objIE.Visible = True

'NPI Registry
objIE.Navigate2 "objIE.Visible = True

End Sub
 
Actually the last thread I posted doesn't work the below works well based on your first code...thank you.

Can you go a bit further on how exactly to start filling out some of the forms on any of these sites?

Also do you know you a code snipet that would close out webpages with the same names (i.e. RevolutionHealth.com, WebMD.com, etc) before I launched these below code? I don't need stack after stack of open webpages...

Thanks so much for your help on this already...

Sub Search()

Dim objIEREV
Dim objIEWP
Dim objIEMD
Dim objIEGov
Dim objIEFSMB
Dim objIEGoogle
Dim objIENPI

Set objIEREV = CreateObject("InternetExplorer.Application")
objIEREV.Visible = False
Set objIEWP = CreateObject("InternetExplorer.Application")
objIEWP.Visible = False
Set objIEMD = CreateObject("InternetExplorer.Application")
objIEMD.Visible = False
Set objIEGov = CreateObject("InternetExplorer.Application")
objIEGov.Visible = False
Set objIEFSMB = CreateObject("InternetExplorer.Application")
objIEFSMB.Visible = False
Set objIEGoogle = CreateObject("InternetExplorer.Application")
objIEGoogle.Visible = False
Set objIENPI = CreateObject("InternetExplorer.Application")
objIENPI.Visible = False
'Revolutionhealth.com

objIEREV.Navigate2 "objIEREV.Visible = True

'Whitepages.com
objIEWP.Navigate2 "objIEWP.Visible = True

'WebMD.com
objIEMD.Navigate2 "objIEMD.Visible = True

'Medicare.gov
objIEGov.Navigate2 "objIEGov.Visible = True

'FSMB.org
objIEFSMB.Navigate2 "objIEFSMB.Visible = True

'Google.com
objIEGoogle.Navigate2 "objIEGoogle.Visible = True

'NPI Registry
objIENPI.Navigate2 "objIENPI.Visible = True

End Sub
 
I tried to take a stab at what it was that you posted...
I am running into a bug on line WScript.Sleep 10....


Sub WhitePagesEntry()

Set WshShell = CreateObject("WScript.Shell")
Set objIEWP = CreateObject("InternetExplorer.Application")
objIEWP.navigate2 "While objIEWP.busy
WScript.Sleep 10
Wend
objIEWP.Visible = True
WScript.Sleep 2000
WshShell.AppActivate "Name or Category"
Name = "HCA"
WshShell.SendKeys Name
WScript.Sleep 300
WshShell.SendKeys "{TAB}"
WScript.Sleep 300
WshShell.SendKeys "Zip"
WScript.Sleep 300
WshShell.SendKeys "{TAB}"
WScript.Sleep 300
WshShell.SendKeys "{TAB}"
WScript.Sleep 300
WshShell.SendKeys "{TAB}"
WScript.Sleep 300
WshShell.SendKeys "{Enter}"
End Sub
 
I am running into a bug on line WScript.Sleep 10....
What are you getting? That is just a command to tell the PC to wait 10 milliseconds. Nothing fancy with a Wscript.Sleep.



I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Error 424
Object Required Error

Not sure...?
 
More than likely the problem is that the IE object has not finished creating at that point. Add a sleep command just before the While command. I would suggest sleepign for at least a second which is 1000 milliseconds, so Wscript.Sleep 1000.

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Anyway, have a look here:
faq707-6399

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Error 424
Object Required Error

Seems like you don't use a VBS script.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top