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

Newbie help - Navigate to a varible url bassed on a list/database

Status
Not open for further replies.

Randazd

Technical User
Oct 12, 2016
1
AU
Hey tek-tipper's
I'm rather unskilled when it comes to writing vbs scripts, however a few months back I decided I would look into automating a few web forms and with some help from the community I was able to successfully automate a few of my daily tasks.

I now have another idea that would significantly decrease my current work load.

Due to an influx of unforseen data, I now have an overload of webpforms that need to be completed.

What's required:
VBS script that opens IE and navigates to a variable URL

If a pop up appears,(only appears on some of the url's) script clicks ok.

Waits for webpage to load - Note the URL loads quickly however the JavaScript webpage is a lot slower.

make a selection from a drop box

make another selection from a drop box

click submit.


Rather simple, but here is where I'm lost.
Once the form is completed it needs to go the 'next URL' and perform the same task.

Now as I mentioned at the start of this post the URL varies for each form. However its only that last part of the URL that varies. See the below example the URL remains the same only the id changes

I have a list with hundreds of id's that all need to be updated.

As mentioned earlier I have pre populated forms in the past but nothing that needs to reference to a list.

here's all I know..

Dim URL

Dim IE

Dim ID

Set objIE = CreateObject("InternetExplorer.Application")

Call objIE.Navigate(" '<-- Don't know how insert id referenced from a list

objIE.Visible = True

Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) : Loop '<-- load url
WScript.Sleep(2500) '<-- Wait for webpage JavaScript (can take 20 seconds)

IE.Document.getElementByName("oper_select10").value = "1" 'select first drop down box (not working)

IE.Document.getElementByName("oper_select6").value = "1" 'select second drop down box (not working)

IE.Document.getElementByName("I2").Click 'Submit form (not working)

WScript.Sleep(2500)

Then the script needs to loop but with a different id..

I'm also curious why even the basic's of selecting my drop down box don't work any help or idea's is greatly appreciated.

Thank you in advance!
 
If you have a list of the IDs, you can use For Each...Next to loop through the list and concatenate the ID to the URL:

Dim IDList As New List(Of String)

Dim ThisURL As String = " 'note there's no ID

'code here to fill the list. Let me know if you need help with this

Dim URL

Dim IE

Set objIE = CreateObject("InternetExplorer.Application")

For Each sID As String In IDList

Call objIE.Navigate("[red] & sID[/red]) 'concatenate the current ID to the URL​

objIE.Visible = True​

Do Until objIE.ReadyState = PAGE_LOADED : Call WScript.Sleep(100) : Loop '<-- load url​
WScript.Sleep(2500) '<-- Wait for webpage JavaScript (can take 20 seconds)​

IE.Document.getElementByName("oper_select10").value = "1" 'select first drop down box (not working)
IE.Document.getElementByName("oper_select6").value = "1" 'select second drop down box (not working)​

IE.Document.getElementByName("I2").Click 'Submit form (not working)​

WScript.Sleep(2500)​
Next



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top