?
Solved

Automating IE with Excel VBa

Posted on 2010-11-19
6
Medium Priority
?
366 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Suggested Courses

807 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