A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Programming
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How can we paste data on Google.com



 
 
Thread Tools Display Modes
  #1  
Old March 28th 17, 09:43 AM posted to microsoft.public.excel.programming
Vipul Purohit
external usenet poster
 
Posts: 1
Default How can we paste data on Google.com

Hi FOlks

I have successfully copied the range and opened the internet explorer and unable to paste it in google.com here is code.. I am quite new with VBA, I am still learning so many things. I want this code to copy the user selected value and input it on Google.com and hit enter or search


Can anybody help... please?

Sub Googlesearch()

Dim WorkRng As Range
On Error Resume Next
xTitleId = "AddForExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
Ws = WorkRng.Copy

Dim ie As Object
Set ie = CreateObject("INTERNETEXPLORER.APPLICATION")
ie.NAVIGATE "http://www.Google.com"
ie.Visible = True
ie.activate.sendkey"^v" &"{ENTER}


End Sub
Ads
  #2  
Old April 1st 17, 12:12 AM posted to microsoft.public.excel.programming
isabelle
external usenet poster
 
Posts: 99
Default How can we paste data on Google.com

Hi,

Here is an example to navigate to google page and another to see Web Objects Name
You must add the Microsoft HTML Objects Library referenceand the Microsoft
Internet Control references

Sub Googlesearch()
Dim i As Integer
Dim IE As InternetExplorer
Dim maPageHtml As HTMLDocument
Dim Helem As IHTMLElementCollection
Set IE = CreateObject("internetExplorer.Application")
IE.Visible = True
IE.navigate "http://www.google.ca/"
Do Until IE.readyState = READYSTATE_COMPLETE
DoEvents
Loop
Set maPageHtml = IE.Document
Set Helem = maPageHtml.getElementsByTagName("input")
For i = 0 To Helem.Length - 1
If Helem(i).getAttribute("name") = "q" Then 'name "q" is the name of
searched words box
Helem(i).innerText = "Word to look for" ' or WorkRng
Helem(i + 1).Click 'Search button comes just after q, so i + 1
End If
Next
End Sub

Sub WebObjectsName()
Dim i As Integer
Dim IE As InternetExplorer
Dim maPageHtml As HTMLDocument
Dim Helem As IHTMLElementCollection
Set IE = CreateObject("internetExplorer.Application")
IE.Visible = True
IE.navigate "http://www.google.ca/"
Do Until IE.readyState = READYSTATE_COMPLETE
DoEvents
Loop
Set maPageHtml = IE.Document
Set Helem = maPageHtml.getElementsByTagName("input")
For i = 0 To Helem.Length - 1
Range("A" & i + 1) = Helem(i).getAttribute("name")
Range("B" & i + 1) = Helem(i).getAttribute("value")
Next
End Sub

isabelle

Le 2017-03-28 √* 04:43, Vipul Purohit a √©crit :
> Hi FOlks
>
> I have successfully copied the range and opened the internet explorer and unable to paste it in google.com here is code.. I am quite new with VBA, I am still learning so many things. I want this code to copy the user selected value and input it on Google.com and hit enter or search
>
>
> Can anybody help... please?
>
> Sub Googlesearch()
>
> Dim WorkRng As Range
> On Error Resume Next
> xTitleId = "AddForExcel"
> Set WorkRng = Application.Selection
> Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
> Ws = WorkRng.Copy
>
> Dim ie As Object
> Set ie = CreateObject("INTERNETEXPLORER.APPLICATION")
> ie.NAVIGATE "http://www.Google.com"
> ie.Visible = True
> ie.activate.sendkey"^v" &"{ENTER}
>
>
> End Sub
>

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
EXCEL PASTE DOES NOT CHANGE DATA - PASTE DOESN'T WORK! robin l Excel Worksheet Functions 7 April 16th 09 07:56 PM
Create Macro to Copy and Paste into Google Maps Bryan Excel Programming 0 October 11th 07 05:29 PM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM
Google Bob Phillips Excel Discussion (Misc queries) 4 December 2nd 04 05:44 PM
A pun on Google steve Excel Programming 6 August 4th 03 03:47 PM


All times are GMT +1. The time now is 12:42 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright ©2004-2017 ExcelBanter.
The comments are property of their posters.