×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Excel VBA Not Sending F keys to Attachmate

Excel VBA Not Sending F keys to Attachmate

Excel VBA Not Sending F keys to Attachmate

(OP)
Using Excel VBA and Attachmate EXTRA! X-treme I am running into issues sending function keys ( <F9> and <F10>)

Here is the code snippet. It is copying data from a csv file and pasting it into Attachmate. To move to the next screen, the F10 key must be pressed. This is not passing through.

I have also tried going the route of trying to access the window manually using AppActivate and to send keys as {f9} and {f10}; but this also does not work.
The tab, down, enter SendKeys all work, including the oSess.Screen.Paste.

Is anyone able to help me figure this out?

Quote (Excel VBA)


           Case "WHATIF"
                ReDim wbs(1)
                wbs(0) = "C:\TEST1.CSV"
                wbs(1) = "C:\TEST2.CSV"
            
                For j = 0 To 1
                    Workbooks.Open (wbs(j))
                    Set ws = ActiveWorkbook.ActiveSheet
                    
                    Application.Wait (Now + TimeValue("0:00:03"))
                    ws.Range("A1:H1").Copy
                    oSess.Screen.Paste
                    oSess.Screen.SendKeys "<F10>"
                    ws.Range("A2").Copy
                    oSess.Screen.Paste
                    oSess.Screen.SendKeys "<F10>"
                    tickerCount = ws.Range("A" & Rows.Count).End(xlUp).Row
                    ws.Range("A3:H" & tickerCount).Copy
                    oSess.Screen.Paste
                    For k = 3 To tickerCount
                        oSess.Screen.SendKeys "<UP>"
                    Next k
                    
                    For k = 3 To tickerCount
                        oSess.Screen.SendKeys "<F9>"
                        oSess.Screen.SendKeys "<TAB>"
                        ws.Range("I" & k).Copy
                        oSess.Screen.Paste
                    Next k
                    
                    oSess.Screen.SendKeys "<F10>"
                    oSess.Screen.SendKeys "<DOWN>"
                    oSess.Screen.SendKeys "<ENTER>"
    
                    Call oSess.Screen.WaitForString("RETURN TO BLOCK ORDER STATUS", , , , , 10000)
                    oSess.Screen.SendKeys "<DOWN>"
                    oSess.Screen.SendKeys "<DOWN>"
                    oSess.Screen.SendKeys "<ENTER>"
                Next j 

RE: Excel VBA Not Sending F keys to Attachmate

Hi,

A former PA guy here (circa 1960).

I assume that your keyboard mapping is such that F9==PF9 & F10==PF10 and therefore you can perform each of those commands manually with expected paging results. Yes?

And for no extra charge...
"copying data from a csv file and pasting it into Attachmate"
Coding in Extra VB is like driving a Yugo compared to coding in Excel VBA, which is like driving a Navigator by comparison.


Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Excel VBA Not Sending F keys to Attachmate

(OP)
Sorry- I should have mentioned I did try using <PF10> as well: oSess.Screen.SendKeys "<PF10>"
This did not work.

When I pause the code in Excel VBA after it fails to send the F10 key, I can manually press the F10 in the window directly and resume the code.
If I change the F10 to say a random string like "HI", it will write "HI" in the window, so it doesn't appear to be a lost focus issue.

Any thoughts on what could be the cause of this? Or potential work-arounds?

RE: Excel VBA Not Sending F keys to Attachmate

CLEAR and then try using this format...

CODE

oSess.Screen.SendKeys ("<PF10>") 
...or...

CODE

oSess.Screen.SendKeys "<PF10>" 

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Excel VBA Not Sending F keys to Attachmate

(OP)
What am I clearing - it didn't seem to do anything? Referring to the api documentation, I see it as clearing an object... http://docs.attachmate.com/extra/x-treme/apis/com/...

With oSys as my object, I tried:

CODE -->

oSys.Waits.Clear
oSess.Screen.SendKeys "<PF10>"
oSess.Screen.SendKeys ("<PF10>")
oSess.Screen.SendKeys "<PF10>" 

But all three failed to send the F10 key to the screen.

RE: Excel VBA Not Sending F keys to Attachmate

Have you checked your keyboard mapping?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Excel VBA Not Sending F keys to Attachmate

(OP)
What's the best way to check that?

Pressing F10 manually works as intended.
And using a site like https://www.keyboardtester.com/tester.html ; correctly identifies my key pressed as F10.

RE: Excel VBA Not Sending F keys to Attachmate

I'm out of options. Sorry.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Excel VBA Not Sending F keys to Attachmate

(OP)
No worries. I'll keep monitoring this thread and will post a solution when I figure it out - unless its posted here first of course :)

RE: Excel VBA Not Sending F keys to Attachmate

I continue to ruminate on this.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Excel VBA Not Sending F keys to Attachmate

(OP)
Skip - you were right. It was keyboard mapping inside AttachMate; not the OS.

In EXTRA!X-Treme you access this from the ribbon by selecting: Edit-->Settings-->Keyboard Maps-->Edit--> (Double click on key)--> (Review the Keystrokes value listed)
In my case, F10 is remapped as: 

Thanks for pointing me in the right direction!
-Al

RE: Excel VBA Not Sending F keys to Attachmate

I suspected keyboard mapping all along. That can be tricky. It's been a long time since I directly interacted with a mainframe via a terminal emulator.

BTW, if you do a lot of screen scraping, you might consider a more long-term solution for 1) defining any screen in a reference table and 2) coding to use such a table to capture every field on a screen and place that data in a table in an Excel workbook.

In that way you will need only one set of procedures to capture the data from any screen thats defined in your reference table. It usually took me maybe 15 minutes to add such data to the table for a new screen.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Excel VBA Not Sending F keys to Attachmate

(OP)
Thanks!

I'm actually going the other way (but I do scrape the entire screen in other jobs like you describe)

I'm receiving input that needs to be processed in the mainframe which has no way to be loaded systematically.
Currently it is key-punched manually or copy/pasted by associates.

So I'm navigating through screens, relying on search for strings to ensure I'm on the right page before pasting in data, and then running processes (using those pesky F-keys).

RE: Excel VBA Not Sending F keys to Attachmate

Quote:

Currently it is key-punched manually…

Wow. Are they still using key-punch cards for input in your establishment?

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: Excel VBA Not Sending F keys to Attachmate

(OP)
Not quite (I really just mean type by hand), but it certainly feels that way at times.

RE: Excel VBA Not Sending F keys to Attachmate

Last time I used a key-punch and card sorter was in the late 1979s.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close