• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to use textbox from Multiple Webpages using VBA

Bhupesh

New Member
Hi Guys,

I have created a macro which is automatically open the IRCTC website and logon by entering Login Id and Password but then i am unable to use the textbox which is in the second Page.

so anyone can help me in this matter.

Regards
Bhupesh Kothari
 
Hi Bhupesh ,

A lot of members of this forum may be willing to help ; but if you expect that others will :

1. Find out the URL of the website you have mentioned

2. Write the macro to logon to the website

3. In case the person who writes the code does not have an account with the website , they will take the trouble to create an account

4. Find out which textbox you are referring to

5. Write the code to resolve your problem

6. Upload the complete code / workbook

then , you may have to wait for some time.

If you want to get a solution faster , upload your workbook with what ever code you have already developed ; mention your user name and password , and specify the textbox which you are not able to use.

Narayan
 
Sub Fill_Website_Textbox()
Dim objIE As SHDocVw.InternetExplorer
Dim OrgBox, orgbox1, orgbox2, orgbox3, elementCol As HTMLInputElement
Set objIE = New SHDocVw.InternetExplorer
objIE.navigate "https://www.irctc.co.in/"
objIE.Visible = True
Do While objIE.readyState < 4: Loop
Set OrgBox = objIE.document.getElementById("username")
Set orgbox1 = objIE.document.getElementById("password")
Set orgbox2 = objIE.document.getElementById("button")
OrgBox.Value = "------" 'What ever is the user Id
orgbox1.Value = "-----" 'What ever is the password
orgbox2.Click
Do Until Not objIE.Busy And objIE.readyState = 3
DoEvents
Loop


'elementCol.Value = "CSTM"
'objIE.Visible = True
'Set orgbox3 = objIE.Document.getElementById("stationFrom")
'orgbox3.Value = "CSTM"
'Set ORGBOX4 = objIE.Document.getElementById("stationTo")
'ORGBOX4.Value = "HYB"
End Sub

Above is the Code which login to the IRCTC and type the username and password automatically and also click on the button but there after when i try to use the object stationfrom and stationto it gives me an error i know this is because of URL has been changed but cannot get the answer to resolve

so please help

Bhupesh
 
Hi Bhupesh ,

Please wait for a day or two ; I have an account at IRCTC ; let me try out the code , and see how far I can get.

Narayan
 
@ narayank991
it will be really very helpful for me.. :)
I always got RAC / Waiting list..
and in this festival season.. I dont think any VBA / Code able to handle this naughty monster site.. :)
 
Hi Bhupesh,

This worked for me. I am able to do the station search and get the train list. The code need to be tweaked to add some more parameters like date of search, quota type (Tatkal, General) etc. in case to be customized.

However, are we doing the right thing by speeding up our activites on this public website to our own custom needs. The way the website is designed and exposes all the HTML objects which we can control through VBA, it looks like if you know the train number and the travelling class, you can jump through until the seat selection(if available on the website) with a click of a button on Excel.

Sub Fill_Website_Textbox()
Dim objIE As SHDocVw.InternetExplorer
Dim OrgBox, orgbox1, orgbox2, orgbox3, orgbox4, orgbutton5, elementCol As HTMLInputElement
Set objIE = New SHDocVw.InternetExplorer
objIE.navigate "https://www.irctc.co.in/"
objIE.Visible = True
Do While objIE.readyState < 4: Loop
Set OrgBox = objIE.Document.getElementById("username")
Set orgbox1 = objIE.Document.getElementById("password")
Set orgbox2 = objIE.Document.getElementById("button")
OrgBox.Value = "----------" 'What ever is the user Id
orgbox1.Value = "--------" 'What ever is the password
orgbox2.Click
'Do Until Not objIE.Busy and 'And objIE.readyState = 3
'
'DoEvents
'Loop
Do
Set orgbox3 = objIE.Document.getElementById("stationFrom")
Set orgbox4 = objIE.Document.getElementById("stationTo")
Set orgbutton5 = objIE.Document.getElementById("Submit")
DoEvents
Loop While orgbox3 Is Nothing Or orgbox4 Is Nothing Or orgbutton5 Is Nothing Or objIE.Busy
'elementCol.Value = "CSTM"
objIE.Visible = True
orgbox3.Value = "CSTM"
orgbox4.Value = "HYB"
orgbutton5.Click
End Sub
 
Hi Sriram ,

I am sure you cannot do anything using VBA which you could not have done manually ! The website is secure enough.

Automating manual actions using VBA is not the same as hacking ; there is absolutely nothing illegal in using VBA to access this website , just as there is nothing illegal in accessing other public websites such as the BSE /NSE ,...

Narayan
 
Hi,

Can we add date and other fields also to the above code if yes can we have the code please as i tried but not succed

Bhupesh Kothari
 
Back
Top