PDA

View Full Version : Solved: is it possible to make connection between vba and site on the internet?



Nader
02-21-2011, 01:52 AM
is it possible to make connection between vba and site on the internet?
example: by print the data in cells to the textbox on the site

Nader
02-21-2011, 11:04 AM
I found this code but it's only open the site example google, so how to print data in cell or range in sheet to the Textbox google
Dim upcCode
Dim myTextField As Object
upcCode = "0001234512345"
Set appIE = CreateObject("INTERNETEXPLORER.APPLICATION")
appIE.navigate "http://google.com"
appIE.Visible = True
Do While appIE.busy

Nader
02-21-2011, 04:43 PM
I tried this way but didn't success .. I don't if the code mistake or the name of textbox of google mistake.
Dim upcCode
Dim myTextField As Object
upcCode = "0001234512345"
Set appie = CreateObject("INTERNETEXPLORER.APPLICATION")
appie.navigate "http://google.com"
appie.Visible = True
appie.document("Search").Value = Sheets(1).Range("a6").Value

mdmackillop
02-21-2011, 05:28 PM
Try a search on the site here or on Google. Here's one (http://vbadud.blogspot.com/2008/05/google-search-using-vba.html) I found which may assist.
An examination of this code by Oorang may point you in the right direction.

Public Sub LaunchGamil()
Const strURL_c As String = "http://mail.google.com"
Const strUsr_c As String = "MyName"
Const strPwd_c As String = "ABC123"
Dim objIE As SHDocVw.InternetExplorer
Dim ieDoc As MSHTML.HTMLDocument
Dim tbxPwdFld As MSHTML.HTMLInputElement
Dim tbxUsrFld As MSHTML.HTMLInputElement
Dim btnSubmit As MSHTML.HTMLInputElement
On Error GoTo Err_Hnd
'Create Internet Explorer Object
Set objIE = New SHDocVw.InternetExplorer
'Navigate the URL
objIE.Navigate strURL_c
'Wait for page to load
Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
'Get document object
Set ieDoc = objIE.Document
'Get username/password fields and submit button.
Set tbxPwdFld = ieDoc.all.Item("Passwd")
Set tbxUsrFld = ieDoc.all.Item("Email")
Set btnSubmit = ieDoc.all.Item("signIn")
'Fill Fields
tbxUsrFld.Value = strUsr_c
tbxPwdFld.Value = strPwd_c
'Click submit
btnSubmit.Click
'Wait for page to load
Do Until objIE.ReadyState = READYSTATE_COMPLETE: Loop
Err_Hnd: '(Fail gracefully)
objIE.Visible = True
End Sub

Nader
02-21-2011, 06:06 PM
it show me this error for this line : User-defined type not defined

Dim objIE As SHDocVw.InternetExplorer

both of the codes are very complicated to me I'm very beginner

Nader
02-22-2011, 04:40 AM
this code succeed with me

Set appie = CreateObject("INTERNETEXPLORER.APPLICATION")
appie.navigate "http://google.com"
appie.Visible = True
Do While appie.busy
DoEvents
Loop
appie.document.all.Item("q").Value = "vbaexpress"
thank you for help!