ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Tab Keystroke in Excel (https://www.excelbanter.com/excel-discussion-misc-queries/139143-tab-keystroke-excel.html)

Snakeoids

Tab Keystroke in Excel
 
Greetings,
I have data in Excel that I want to copy and paste into another application.
Each row in Excel has approx 13 cells of data to be pasted into 13 fields in
the other program.
The problem is that when I paste the data into the other application, the
cursor tries to paste all of the data into the field that it's currently in;
the cursor does not paste into the respecive fields in this other program.
When I manually press the TAB key the cursor will move, so I figured that if
I ingrain a TAB keystroke into my Excel data that it would work, but no luck.
Any ideas on this one. It's a lot of data to enter manually and the clock
is ticking for me. Thanks in advance.

Snakeoids.


Greg Wilson

Tab Keystroke in Excel
 
Assuming it's not an ms office program (VBA would be the way to go) then
check out Application.SendKeys. You may want to use the Replace function to
change special characters in your text. For example, the plus sign "+" is
recognized as the Shift key instead of a plus sign.

This is an *illustrative* example that includes a routine to change special
characters recognized by the SendKeys method to their normal text. Not
tested:-

With Application
For Each c In Range("A1:A200").Cells
'Replace necessary for A1:A200 because contains text
txt = c.Value
txt = Replace(txt, "+", "{+}")
txt = Replace(txt, "%", "{%}")
txt = Replace(txt, "(", "{(}")
txt = Replace(txt, ")", "{)}")
txt = Replace(txt, "^", "{^}")
.SendKeys txt & "{TAB}", True
'Replace not necessary for c(1, 7) and c(1, 8) because numeric
.SendKeys c(1, 7) & "{TAB}{TAB}{TAB}", True
.SendKeys c(1, 8) & "{TAB}", True
Next
End With

Another problem with SendKeys is that it won't recognize an error state in
the destination program. If the dest. program pops up an error message it
will keep pounding away. I've used API code to continually check the window
caption to make sure it's what it's supposed to be. If not, abort. This would
probably be too confusing to post and the above should get you going.

Greg


"Snakeoids" wrote:

Greetings,
I have data in Excel that I want to copy and paste into another application.
Each row in Excel has approx 13 cells of data to be pasted into 13 fields in
the other program.
The problem is that when I paste the data into the other application, the
cursor tries to paste all of the data into the field that it's currently in;
the cursor does not paste into the respecive fields in this other program.
When I manually press the TAB key the cursor will move, so I figured that if
I ingrain a TAB keystroke into my Excel data that it would work, but no luck.
Any ideas on this one. It's a lot of data to enter manually and the clock
is ticking for me. Thanks in advance.

Snakeoids.



All times are GMT +1. The time now is 02:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com