View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
matt matt is offline
external usenet poster
 
Posts: 73
Default Sending Keys from Excel to Internet Explorer


Below you'll find the code for which I'm basing my stream of thought.
I'm thinking that you can do something similar with Internet Explorer.
I have tried web querying (and I'm familar with how to do that), but
webquering doesn't do well with websites that require you to login. It
will follow you up to the point that you login and then it won't go any
further. So, if you have any other ideas then I'm open for
suggestions. Thanks.

Option Explicit
Global MySystem As Object
Dim MyEDPThing As Object
Dim MySessions As Object
Dim MySession As Object
Dim MFlag As Integer
Global MyScreen As Object
Global MyUserID As String
Global MyPassword As String

Sub LOGONEXTRA()

Screen.MousePointer = 11

'OPEN EXTRA!:
Set MySystem = CreateObject("EXTRA.System")
Set MyEDPThing = MySystem.Sessions.Open("c:\Program
Files\E!pc\Sessions\Session2.EDP")

'THE MAINFRAME IS OPEN:
MFlag = 1

'VERIFY SYSTEM OBJECT:
If (MySystem Is Nothing) Then
MsgBox "Could not create the EXTRA System object. Stopping
Connection to Extra!."
End
End If

'CREATE A SESSIONS OBJECT (a collection of your sessions):
Set MySessions = MySystem.Sessions
If (MySessions Is Nothing) Then
MsgBox "Could not create the Sessions collection object.
Stopping Connection to Extra!"
End
End If

'SET YOUR SESSIONS OBJECT:
Set MySession = MySystem.ActiveSession
If (MySession Is Nothing) Then
MsgBox "Could not create the Session object. Stopping
Connection to Extra!"
End
End If

'MINIMIZE EXTRA!:
' MySession.WindowState = 0

'CHECKS TO SEE THAT THE SESSION IS VISIBLE:
If Not MySession.Visible Then MySession.Visible = True

'CREATE THE SCREEN OBJECT AND MAKE SURE IT IS A VALID OBJECT:
Set MyScreen = MySession.Screen
If (MyScreen Is Nothing) Then
MsgBox "Could not create the Screen object. Stopping
Connection to Extra!"
End
End If

'WAIT FOR SCREEN:
MyScreen.WaitHostQuiet (3000)

'MOVE TO TPX SCREEN:
If MyScreen.Search("HOST", 2, 1) = "HOST" Then
MyScreen.SendKeys ("tpx101<Enter")
MyScreen.WaitHostQuiet (3000)

'Send user id and password to tpx screen:
If MyScreen.Search("Userid:", 14, 5) = "Userid:" Then
'MyScreen.SendKeys (Left(CurUser, 7))
MyScreen.SendKeys (MyUserID)
MyScreen.SendKeys ("<TAB")
'Get Password:
'MyPassword = InputBox("Enter Your Mainframe
Password For " & Left("ACUS345", 7) & ":", "DLP - Update IMS")
MyScreen.SendKeys (MyPassword)
MyScreen.SendKeys ("<Enter")
MyScreen.WaitHostQuiet (3000)
End If
End If

Screen.MousePointer = 0

End Sub


Gonzo wrote:
Not quite following where the example code comes from etcetera...
It might be easier to use Excel 2003's built-in web query
functionality. Go to Data Import external data New web query.
Check Excel's help file or online tutorials to use web queries in Excel
and you might just find that it's what you need.

matt schreef:

I have very limited programming knowledge and am a beginner.

I have code to open Internet Explorer from Excel. The website I am
accessing requires me to input a username and password. I want to know

if there is a way to do that from Excel.


I have an example of some code that opens an application, names the
application as MyScreen, and then runs the following:


If MyScreen.Search("Userid:",14, 5) = "Userid:" Then
MyScreen.SendKeys("tpx101<Enter")
.....


I'm assuming that the "Search" looks for the ("Userid:") text, but I
have no idea what the ",14, 5) = "Userid:" is for.


My thinking is that I can do a similar thing with the Internet Explorer

Browser--name it, and then send keys to the username and password
boxes. I'm sure there is a better way, but I'm working with what I
have.


Once I've logged into the internet site I then have to click on two
separate links to get to a point where I can input information, click a

submit button, and then obtain results from a separate browser that
opens with the results output in the form of a hyperlink. I click on
the results output hyperlink and I have what I'm looking for.


Any ideas for using Excel code to run through these steps is much
appreciated.


Thanks,


Matt