Solved

Automating IE with Excel VBa

Posted on 2010-11-19
6
353 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now