Solved

Automating IE with Excel VBa

Posted on 2010-11-19
6
357 Views
Last Modified: 2012-06-22
I have the following code for the webpage (which is in the code). When I use it I get the Run time error 438 (Object doesn't support this property method) highlighting the IE.Document.getElementsByName("CustID").Value = "Username1".

I would like the username to be entered automatically and continue button next to the username box to be clicked automatically.

How can I achieve this?

Sub aa2()

Dim IE As Object
  
  Set IE = CreateObject("InternetExplorer.Application")
  
  IE.Visible = True
  IE.Navigate "www2.netxpro.com"
  ' Wait for the page to load.
  Do While IE.Busy Or IE.ReadyState <> 4
    DoEvents
  Loop
  
  IE.Document.getElementsByName("CustID").Value = "Username1"

End Sub

Open in new window

0
Comment
Question by:awesomejohn19
  • 3
  • 3
6 Comments
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34175142
Replace this

IE.Navigate "www2.netxpro.com"

with

IE.Navigate "https://www2.netxpro.com/salogin.htm"

and try now
0
 

Author Comment

by:awesomejohn19
ID: 34175164
Thanks for your response. II get the same error
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34175177
How dumb of me...

Try this and it will work....

Sub Sample()
    Dim IE As Object
  
    Set IE = CreateObject("InternetExplorer.Application")
  
    IE.Visible = True
    
    IE.Navigate "https://www2.netxpro.com/salogin.htm"
    ' Wait for the page to load.
    Do While IE.Busy Or IE.ReadyState <> 4
        DoEvents
    Loop
  
    IE.Document.getElementById("CustID").Value = "Username1"

End Sub

Open in new window


forgot to mention about replacing getElementsByName by getElementById lolzzz
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:awesomejohn19
ID: 34175203
Thanks that works like charm. For the rest of the question, how can I click the continue button.

0
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 500 total points
ID: 34175261
Lolzzz

I saw the question coming...

Sub Sample()
    Dim IE As Object
  
    Set IE = CreateObject("InternetExplorer.Application")
  
    IE.Visible = True
    
    IE.Navigate "https://www2.netxpro.com/salogin.htm"
    ' Wait for the page to load.
    Do While IE.Busy Or IE.ReadyState <> 4
        DoEvents
    Loop
  
    IE.Document.getElementById("CustID").Value = "Username1"
    IE.Document.getElementById("submit").Click
End Sub

Open in new window

0
 

Author Closing Comment

by:awesomejohn19
ID: 34175274
thanks a lot
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question