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?
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
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,
Just traded in my OLD subtlety...
for a NUance!
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
RE: Excel VBA Not Sending F keys to Attachmate
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
CODE
CODE
Skip,
Just traded in my OLD subtlety...
for a NUance!
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
RE: Excel VBA Not Sending F keys to Attachmate
With oSys as my object, I tried:
CODE -->
But all three failed to send the F10 key to the screen.
RE: Excel VBA Not Sending F keys to Attachmate
Skip,
Just traded in my OLD subtlety...
for a NUance!
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
RE: Excel VBA Not Sending F keys to Attachmate
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
Skip,
Just traded in my OLD subtlety...
for a NUance!
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
RE: Excel VBA Not Sending F keys to Attachmate
RE: Excel VBA Not Sending F keys to Attachmate
Skip,
Just traded in my OLD subtlety...
for a NUance!
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
RE: Excel VBA Not Sending F keys to Attachmate
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: [010q
Thanks for pointing me in the right direction!
-Al
RE: Excel VBA Not Sending F keys to Attachmate
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,
Just traded in my OLD subtlety...
for a NUance!
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
RE: Excel VBA Not Sending F keys to Attachmate
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
Wow. Are they still using key-punch cards for input in your establishment?
Skip,
Just traded in my OLD subtlety...
for a NUance!
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
RE: Excel VBA Not Sending F keys to Attachmate
RE: Excel VBA Not Sending F keys to Attachmate
Skip,
Just traded in my OLD subtlety...
for a NUance!
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein