Putting Value in Text box in VBA - Google Alerts

ddotson

Board Regular
Joined
Nov 9, 2004
Messages
57
Hello all

I am attempting some code that will utilize Excel, go out to Google Alerts, add an alert, go back to the spreadsheet, offset to the row below, capture this string, and add the next alert (loop through the list in the column).. I have not yet completed the loop part, as I am stuck on the first input box?


Looking at the element that I am trying to manipulate, I get the following information

'input type="text" placeholder="Create an alert about..." aria-label="Create an alert about..." class tabindex="0"'

So, I do not have a name to work with?


I have the following code, which of course throws an error:




Sub GoogleAlerts()

Dim IE As Object

Dim Alert As String


Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True


Sheets("Sheet1").Select

Range("A2").Select

Do Until ActiveCell.Value = ""

Alert=ActiveCell.Value
ActiveCell.Offset (1,0).Select


IE.navigate "https://www.google.com/alerts"

Application.Wait Now + TimeValue("00:00:02")

IE.document.all("query_div").Value = Alert

Loop

End Sub


Any help would be appreciated!
 
Last edited:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
I have found the solution to completing the textbox with:

IE.document.getElementById("search_box").getElementsByTagName("input")(0).Value = "John Deere"


Now, I am trying to get the page to move to the next step, which will allow me to create the alert by clicking an actual named button - ha ha.. If anyone can help me fire off this "form" so it gets to the next step, that would be great!
 
Upvote 0
Can anyone help me out with the AfterUpdate method of making the web page move to the next step? After I fill in the search box in Google Alerts with the string I want to add to the alert, the page will not move to the next step, i.e., show me the Create Alert button. I believe the AfterUpdate is the way to handle this, per my research last night, although I am not sure how to use it...

Thanks!
 
Upvote 0
This code works! So, if you need to add a bunch of alerts to Google Alerts - this code will allow you to do so by placing your alerts in Column A (under your header). The code assumes that you are already signed into Google Alerts with the email account to which the alerts will be sent.


Sub GoogleAlerts()

Dim IE As Object

Dim Alert As String


Set IE = CreateObject("InternetExplorer.Application")

IE.Visible = True



IE.navigate "https://www.google.com/alerts" 'load the Google Alerts page

Do
DoEvents
Loop Until IE.readyState = 4

Application.Wait Now + TimeValue("00:00:05")

'This is where we start the Loop

Sheets("Sheet1").Select

Range("A2").Select

Do Until ActiveCell.Value = ""

Alert = ActiveCell.Value


IE.document.getElementById("search_box").getElementsByTagName("input")(0).Value = Alert

IE.document.all("create_alert").Click


Sheets("Sheet1").Select
ActiveCell.Offset(1, 0).Select


Loop


MsgBox "Done, *****"


End Sub
 
Last edited:
Upvote 0

Thank you for your sharing/.

I am also facing similiar problem/.

<div class="mssval">
<span class="fr mss_list mss_text">從</span>
<input type="text" class="mss_list val valstart" aria-label="Strike From">
<span class="to mss_list mss_text">至</span>
<input type="text" class="mss_list val valend" aria-label="Strike To">
</div>

Do u get any idea?

Thank you
 
Upvote 0
Loop

ie.document.getElementByClass("mssval").getElementsByTagName("input")(0).Value = "11000"

does not work :(
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,314
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top