Solved

How to Extract String from Web Page and Assign that to Variable in VBA

Posted on 2012-04-09
1
314 Views
Last Modified: 2012-04-26
How to Extract String from Web Page and Assign that to Variable in VBA

Please share the piece of code
0
Comment
Question by:srikanth15
1 Comment
 
LVL 14

Accepted Solution

by:
sungenwang earned 500 total points
ID: 37825792
Here is a piece of code that opened google, populates ID field, then save the ID field in variable 'str'.

Sub test()
    strURL = "https://www.google.com/accounts/ServiceLogin?service=mail&passive=true&rm=false&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F%3Fnsr%3D1%26ui%3Dhtml%26zy%3Dl&ltmpl=default&ltmplcache=2"
    strLoginName = "abcdefg"
    intTimeOut = 10
    
    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Visible = True
    objIE.Navigate2 strURL
    
    If Err Then
        MsgBox "Error with IE object!"
        WScript.Quit
    End If
    
    
    boolTimedOut = False
    Do While objIE.Busy
        Application.Wait DateAdd("s", 10, Now)
        i = i + 1
        If i > CInt(intTimeOut * 10) Then
            boolTimedOut = True
            MsgBox "Timeout expired waiting for IE object to stop loading!"
            Exit Sub
        End If
    Loop
    
    objIE.document.getElementById("Email").Value = strLoginName
    
    Dim str As String
    str = objIE.document.getElementById("Email").Value
    
    MsgBox "str = [" & str & "]"
    
    'objIE.document.getElementById("signIn").Click
    'objIE.Quit
End Sub

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ejb example issues 3 25
copy same as above data 18 37
Web Query 1 20
HELP WITH  INDEX MATCH to look from LEFT TO RIGTH 4 11
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

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