Access Textbox and Button inside the form of a frame of a webpage (1 Viewer)

VBAPro

New member
Local time
Today, 06:21
Joined
Oct 10, 2013
Messages
3
Dear All,

I am writing a macro to automate the filling up some data from excel to company website. I have changed the website name in this post for data protection purpose. The excel will login for different clients by using the combination of username and password for respective clients and then some data are required to be inserted in a text box on a web page, I think the text box is on a form and form is within an iframe, within the web page. Once the data is inserted into text box, one button (Submit), which is also on the same form, is to be clicked.

On the click of a button, the updated data appears on another section, I could not make out if it is an form or frame, which is under the abovementioned form. Once we are happy with the way data appears on the web page, we have to click another button (Update), which is on the same section, to finally updating the data on website.

I wrote the following code to login to the website and then to navigate to the web page where I have to fill up the performance numbers in a text box.

The first problem is how to access the text box inside the form from VBA so that the macro can write a number in that text box and how to access the button to submit the data. The HTML code, which can be seen on click of F12, is attached below.

The second problem is how to access the Update button inside the other section, so that the data will be finally uploaded.

Code:
Sub LoginToCorpAccount()    
    Dim ie As Object
    Set ie = CreateObject("InternetExplorer.Application")
  
    With ie
        .Visible = True
        .navigate "https://kvinvest.com/clients/perf/"        
 
        ' "Submit" button is found but it has no name – that is why
        ‘I have gone through all the elements with Tagname “input”                    
 
        Set objcollection = ie.document.getElementsByTagName("input")
 
        i = 0
        While i < objcollection.Length
            Debug.Print objcollection(i).Name
            If objcollection(i).Name = "login" Then        
                objcollection(i).Value = "silver2"
       
            ElseIf objcollection(i).Type = "password" Then
                objcollection(i).Value = "golden2"
       
            Else
                If objcollection(i).Type = "submit" Then        
                    Set objElement = objcollection(i)
                    objElement.Click
                    GoTo NextStep
       
                End If
            End If
            i = i + 1
        Wend
NextStep:          
‘navigate to the page to upade the data        
.navigate "https://kvinvest.com/clients/perf/?action=CurrentMonth"
 
‘nevigate to the page by further clicking the required link appearing on the above page
                ie.document.all.Item("server_clientr").Click         
   
    End With
    ie.Quit
    Set ie = Nothing
End Sub

The F12 view (HTML) of the web pages shows the following:
<iframe name="PerformanceFrame" id=" PerformanceFrame " src="?action=iframe" frameBorder="0" style="width: 0px; height: 0px;">
<form class="ssc-form" action="https://kvinvest.com/clients/perf/?action=template&tid=signal_server_consumer&noheader=true" method="post" jQuery1381351885765="3">
-<input name="call" type="hidden" value="ssc"/>
-<input name="type" type="hidden" value="subscribe"/>
-<input name="csrf" type="hidden" value="8888888889999999"/>
--<div style="margin-bottom: 3px;">
--<span class="ssc-data-help" rel="ssc-help-provider" jQuery1381351885765="8">
--<input name="server" id="ssc-subscribe-server" style="width: 150px;" type="text"/>
--<input name="" id="ssc-subscribe-apply" style="width: 70px;" type="submit" jQuery1381351885765="4" value="Open"/>



<div id="ssc-consumers-holder"/> - This the line which gets highlighted when I click on the section where the data appears after clicking the submit button, and from here Update button is to be clicked.

Thank you very much for all your help.
 

VBAPro

New member
Local time
Today, 06:21
Joined
Oct 10, 2013
Messages
3
Hi,

I have attached the excel file with the macro inside.

Please have a look at the code and help.

Thanks.
 

Attachments

  • Code.xls
    38 KB · Views: 480

JHB

Have been here a while
Local time
Today, 15:21
Joined
Jun 17, 2012
Messages
7,732
I think you need to take some print screen and show where and what you want!
You have in your code the following comments:
'ABOVE - I am trying to access the textbox where I want to insert the code Pm3gsTgXJ6X5g143 and then would like
'click submit button
'The textbox is in the form which in inside of the frame
'I am gettging Runtime Error "70" - Permission Denied
I do not get any runtime error, so ...
 

VBAPro

New member
Local time
Today, 06:21
Joined
Oct 10, 2013
Messages
3
Hi JHB,

Thanks for your reply. I have attached herewith word file with print screen and my requirement.

When I was looking for the solution to that Runtime Error 70 - Permission Denined, I found something to do with the IE security. I have tried this codes on IE10 (with windows 8 Operating System) and on IE 8 (with Windows XP Operating System).

Would you please let me know which IE and Operating System you are using. Please also let me know your security levels in IE.

Thanks and regards.
 

Attachments

  • Print Screen.zip
    109.7 KB · Views: 589

JHB

Have been here a while
Local time
Today, 15:21
Joined
Jun 17, 2012
Messages
7,732
By me the text box is filled with the code and at message box is popping up asking if I want to subscribe, see attached picture, so I'll say your code run as wanted by me, do you not agree?
I'm running Windows 8.
IE is version 10.
IE security level for Internet is middel.

If you need more information about IE security level, then ask and I'll see if I'm able to make a print screen of it, (but so far I remember I haven't done any change from default setup, normally I'm using Mozilla Firefox).
Do you've the possibility to try on another computer?
 

Attachments

  • SocialSignal.jpg
    SocialSignal.jpg
    86.1 KB · Views: 426
  • IE-10.jpg
    IE-10.jpg
    32.4 KB · Views: 651
  • IE-Ser.jpg
    IE-Ser.jpg
    73.4 KB · Views: 552

Users who are viewing this thread

Top Bottom