Results 1 to 3 of 3

Thread: Excel macro need to know how many internet objects to navigate different screens

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    2

    Excel macro need to know how many internet objects to navigate different screens

    I very new to excel macro. please help me. also suggest me very good material to learn vba concepts.

    See the below code,

    1. Macro should open this link "https://accounts.google.com/ServiceLogin?hl=en&continue=http://www.google.co.in/" and enter account details.
    2. Navigated to google page. Now need to click Google maps link and enter London and click search.

    vb Code:
    1. Public Sub LaunchGamil(username As String)
    2.     Const strURL_c As String = "https://accounts.google.com/ServiceLogin?hl=en&continue=http://www.google.co.in/"
    3.     Const URLmaps As String = "http://maps.google.co.in/maps?hl=en&tab=wl"
    4.     Dim objIE As SHDocVw.InternetExplorer
    5.     Dim objIE1 As SHDocVw.InternetExplorer
    6.     Dim ieDoc1 As MSHTML.HTMLDocument
    7.     Dim ieDoc2 As MSHTML.HTMLDocument
    8.     Dim tbxPwdFld As MSHTML.HTMLInputElement
    9.     Dim tbxUsrFld As MSHTML.HTMLInputElement
    10.     Dim btnSubmit As MSHTML.HTMLInputElement
    11.    
    12.     On Error GoTo Err_Hnd
    13.     'Create Internet Explorer Object
    14.     Set objIE = New SHDocVw.InternetExplorer
    15.     'Navigate the URL
    16.     objIE.Navigate strURL_c
    17.     'Wait for page to load
    18.     Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
    19.     'Get document object
    20.     Set ieDoc1 = objIE.Document
    21.     'Get username/password fields and submit button.
    22.     Set tbxPwdFld = ieDoc1.all.Item("Passwd")
    23.     Set tbxUsrFld = ieDoc1.all.Item("Email")
    24.     Set btnSubmit = ieDoc1.all.Item("signIn")
    25.     'Fill Fields
    26.     tbxUsrFld.Value = username
    27.     tbxPwdFld.Value = password
    28.     'Click submit
    29.     btnSubmit.Click
    30.     'Wait for transistion page to load
    31.     Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
    32.     'Wait for main page to load
    33.     'Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
    34.     While ieDoc1.Busy
    35.     DoEvents  'wait until IE is done loading page.
    36.     Wend
    37.     Set objIE1 = New SHDocVw.InternetExplorer
    38.     objIE1.Navigate URLmaps
    39.     Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
    40.    
    41. Err_Hnd: '(Fail gracefully)
    42.     objIE.Visible = True
    43. End Sub
    Last edited by Hack; Feb 11th, 2012 at 08:30 AM. Reason: Added Highlight Tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width