Solved

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

Posted on 2012-04-09
1
318 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
[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
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

707 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