Passing Data to Internet Browser

G

Guest

I'm trying to write code that will assign data in 3 cells to 3 variables,
i.e. -
strVIN = activecell.offset(0,-3).value
strDate = activecell.offset(0,-2).value
strName = activecell.offset(0,-1).value

Then, I want to open an Internet Browser window (user's default browser),
navigate to a specific website (I have this part down), and then place the
values of my 3 variables into 3 text boxes on the website.

I tried SendKeys using the Tab key and then the variables. Problem with
this is the timing of the action. If the browser window doesn't open soon
enough, the data is pasted in the active cell in Excel.

How can I consistently paste the information in the proper browser locations
every time?
 
G

Guest

Well you can't with the way your going about it Excell VBA can interface with
some windows applications but I don't think that it was ment to the way your
trying to do it seem's like the hard way.

I would suggest using VBS (Visual Basic Script) in conjunction with you
Excell to accomplish this. Although if you are not firmilar with VBS this
could poise a problem.

Unfortuanitly I am not firmillar enough with VBS to show you how to do this
with a code example.
 
G

Guest

I got it. Was checking out www.ozgrid.com and found the following bit of
code that basically says, "until the browser is ready, busy yourself". THEN,
I am able to use SENDKEYS to move to the necessary textboxes and send the
variable data.

Set ie = CreateObject("InternetExplorer.Application")

ie.navigate "https://www.anywhere.com"
Do While ie.busy And Not ie.readystate = 4
DoEvents
Loop

ie.Visible = True

works like a charm :))
 
G

Guest

Hi SyrNO,

Could you post the full code?

I am very interested in passing data to IE.

Many thanks,

Antonio
 
G

Guest

Not a problem, Antonio

Here's the setup: I work for a bank that receives a spreadsheet of Vehicle
information including VIN, Year and Make of the vehicle. There's a website
we have to go to and check for information about this vehicle. Instead of
manually typing the information in (time consuming and potential typing
errors), I was asked to design a macro that would open the site and populate
the text fields with proper data.

VIN information is Column A, Year is Column B and Make is Column C.

Sub LookUpOnInternet()
Dim VIN As String
Dim CurrentRow As String
Dim YR As Integer
Dim MAKE As String
Dim ie As Object

CurrentRow = ActiveCell.Row
VIN = Range("A" & CurrentRow).Value
YR = Range("B" & CurrentRow).Value
MAKE = Range("C" & CurrentRow).Value

Set ie = CreateObject("InternetExplorer.Application")
ie.navigate
"https://corvus.dmv.state.ny.us/titlstat/iviqEnterVehInfo.cfm"
Do While ie.busy And Not ie.readystate = 4
DoEvents
Loop

ie.Visible = True

SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys VIN
SendKeys "{TAB}", True
SendKeys YR
SendKeys "{tab}", True
SendKeys MAKE
End Sub
 
G

Guest

Yes, thank you very much. I was able to make it work myself in the same way.
The
Do While ie.busy And Not ie.readystate = 4
DoEvents
Loop

is the interesting trick.

It works really well and I will use it a lot.

Regards,

Antonio
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top