Results 1 to 6 of 6

Thread: vba code for automation
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Jun 2019
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default vba code for automation

    Dear SirI want to enter data (roll numbers) from excel in site http://rajresults.nic.in/resbserx19.htm and the and extract the data received in excel. I had tried to write the code which is given below but unable to extract percentage or data from site. Please help.
    Code:
    Private Sub CommandButton1_Click()
    Dim IE As ObjectSet IE = CreateObject("InternetExplorer.Application")
    IE.navigate "http://rajresults.nic.in/resbserx19.htm"
    IE.Visible = True
    While IE.busyDoEvents 'wait until IE is done loading page.
    Wend
    IE.document.all("roll_no").Value = ThisWorkbook.Sheets("Sheet1").Range("B2")
    Set doc = IE.document    
    Do While doc.ReadyState <> "complete": DoEvents: Loop    doc.GetElementsByName("B1")(0).Click        strVal = IE.document.all("Percentage").Item(0).innerText    
    ThisWorkbook.Sheets("Sheet1").Range("C2").Value = strVal    
    End Sub
    Last edited by mole999; Jun 8th, 2019 at 01:41 PM. Reason: code tags and tidy

  2. #2
    Board Regular Logit's Avatar
    Join Date
    Aug 2016
    Location
    United States
    Posts
    2,806
    Post Thanks / Like
    Mentioned
    36 Post(s)
    Tagged
    1 Thread(s)

    Default Re: vba code for automation

    .
    The macro, re-written as below ... got me to the first screen requesting the Roll Number and gave me an error for the false number I used :

    Code:
    Option Explicit
    
    
    Sub CommandButton1_Click()
    Dim IE As Object
    Dim doc As Object
    Dim strVal As String
    Set IE = CreateObject("InternetExplorer.Application")
    
    
    IE.navigate "http://rajresults.nic.in/resbserx19.htm"
    IE.Visible = True
    
    
    While IE.busy
        DoEvents 'wait until IE is done loading page.
    Wend
    
    
    IE.document.all("roll_no").Value = ThisWorkbook.Sheets("Sheet1").Range("B2")
    Set doc = IE.document
    
    
    Do While doc.ReadyState <> "complete": DoEvents: Loop
    
    
    doc.GetElementsByName("B1")(0).Click
    strVal = IE.document.all("Percentage").Item(0).innerText
    ThisWorkbook.Sheets("Sheet1").Range("C2").Value = strVal
    
    
    End Sub

    Put your real Roll Number and Name in the appropriate cells and see what happens.

  3. #3
    New Member
    Join Date
    Jun 2019
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: vba code for automation

    I Put the roll no 1706641 in B2 but not getting its percentage in C2. I also need percentage of all the roll numbers entered in B2 in column C2. Please help.
    I am getting run time error '424' object required.
    Note; Roll numbers are increasing by 1.
    Thanks

  4. #4
    Board Regular Logit's Avatar
    Join Date
    Aug 2016
    Location
    United States
    Posts
    2,806
    Post Thanks / Like
    Mentioned
    36 Post(s)
    Tagged
    1 Thread(s)

    Default Re: vba code for automation

    .
    I also need percentage of all the roll numbers entered in B2 in column C2. Please help.
    Sounds like there is a lot more going on with your code than I fully understand.

    You'll need to explain is better detail because I don't understand the importance of the 'percentages' or what the
    expected outcome is.

  5. #5
    New Member
    Join Date
    Jun 2019
    Posts
    5
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: vba code for automation

    Sir, my requirement is that I have roll numbers of few students who have appeared in Board exams. I want to see their results online (http://rajresults.nic.in/resbserx19.htm) and want to store their scored percentages in excel. In one column i will write all the roll numbers like
    Roll No. Percentage
    1706641 90
    1706642 94.5
    1706643 85.5
    and so on
    I need a macro which will pick one roll number at a time and after checking the result its scored percentage will be entered in excel next to its roll no.
    I hope I have make my requirement clear this time.
    Thanks and Regards

  6. #6
    Board Regular Logit's Avatar
    Join Date
    Aug 2016
    Location
    United States
    Posts
    2,806
    Post Thanks / Like
    Mentioned
    36 Post(s)
    Tagged
    1 Thread(s)

    Default Re: vba code for automation

    .
    The PERCENTAGE is downloaded from the website you've listed in the code ?

    If that is the scenario, regretfully I am not familiar with obtaining data from a website. There are many other volunteers on this
    and other forums who are familiar. Hopefully someone else can assist you.

    Thank you for your understanding.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •