Solved

Automating IE with Excel VBa

Posted on 2010-11-19
6
360 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

729 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