Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SendKeys from VBA

Status
Not open for further replies.

DvlDawg

Technical User
Apr 23, 2003
27
US
I can get everything in my code to work except this one thing. I need to send data from my Excel spreadsheet to a session. But all the examples I have seen are not working.

I tried everything in the help files from VB6, the standard ones in Extra! nothing is working. Any suggestions?

I can get it to open the session, but when it does the send key, it is actually putting the strings of text into the macro. I know its working, but not sending it to the session.
 
Could you post an example of the code you're using. To see if i/we can spot anything.

I use the sendkeys method regularly in various macros and have had no problems so i have no idea what's wrong!
 
The code is in a Macro in Excel not Extra. I can do those all day long with no issues. Its crossing it over from VB/Excel is where I am having the problem.
 
Yeah but I don't have anything to go on. How can i tell you what's wrong if i can't see your code.
 
What I am attempting to do is use the macro in excel to key someting to the session from different cells. I can get Extra macro to read from it, but halfway through the code it just stops. No errors, edits, nothing. This is the code I was trying to get to work in the VB editor.

I can get it to open the session just fine, its getting anything else to the screen is my hurdle.


Sub Main()
Dim ReturnValue
ReturnValue = Shell("Session1.EDP", 1)
AppActivate ReturnValue
SendKeys "LOGIN", True
End Sub
 
Hmmm, is this the method you're using to actually open Attachmate? I personally think it's the shell command which is causing you the issues. You need to really create a reference to the attachment object as below:

Dim ExtraSystem as Object

ExtraSystem = CreateObject("EXTRA.System")

If (ExtraSystem Is Nothing) Then
MsgBox "Could not create the EXTRA System object."
Stop
End If

from here you can just use:

Extrasystem.screen.sendkeys ("whatever")

Does this help?

 
No that didnt work, however this did. Now to figure out sending data from a cell to the screen and I will be good to go.

Sub Main()
'--------------------------------------------------------------------------------
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System Is Nothing) Then
MsgBox "Could not create the EXTRA System object. Stopping macro playback."
Stop
End If
Set Sessions = System.Sessions

If (Sessions Is Nothing) Then
MsgBox "Could not create the Sessions collection object. Stopping macro playback."
Stop
End If

Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 Is Nothing) Then
MsgBox "Could not create the Session object. Stopping macro playback."
Stop
End If
If Not Sess0.Visible Then Sess0.Visible = True
'--------------------------------------------------------------------------------
Sess0.Screen.SendKeys ("whatever")
End Sub
 
Oh yeah, sorry. Forgot the SendKeys method was part of the Session object, not the system!
 
That part worked, however after I added more code to it, it just stops with no errors.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top