Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Simulate ALT+TAB in Excel macro

Posted on 2014-08-14
10
Medium Priority
?
3,444 Views
Last Modified: 2014-08-20
Is there a send.keys command to simulate the press of ALT+TAB, to get to what the previous session was.
0
Comment
Question by:RWayneH
10 Comments
 
LVL 46

Expert Comment

by:aikimark
ID: 40263279
    AppActivate "window caption text"   'may be optional
    SendKeys "%{TAB}", True

Open in new window

0
 

Author Comment

by:RWayneH
ID: 40264975
This is not working.  It appears to take focus off the active session in excel, but does not flip the display to continue the macro.  My issue is the sheet that I am ALT+TABing to has a different (random) file name each time.
Any other ideas or why this is not working?
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40265007
You can not step through such code.  How are you launching the routine?

Is the other (prior focus) window also an Excel workbook?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:RWayneH
ID: 40265135
Yes the prior focus is an Excel workbook and when I step through it, it does not do anything.
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40265521
what is the purpose of the focus change from one workbook to another?
0
 

Author Comment

by:RWayneH
ID: 40266068
I am opening a series of files that are from a external system as .xls files, when they are exported they are given a random numeric filename like 34565434543544.xls  the next could be 898989099090.xls  I have over 500 hundred of them to import into a master file, so as I open a file, I am mapping data to the master workbook with a macro.  I am having issues getting back and further to the files that are open.  No problem with the master file because that name is static, it is the other one that is giving me issues to get to.
0
 
LVL 46

Expert Comment

by:aikimark
ID: 40266094
It would be better to automate the import, where the VBA code iterates the workbooks.
0
 
LVL 36

Expert Comment

by:Norie
ID: 40266228
Where are the files saved?
0
 
LVL 19

Accepted Solution

by:
Richard Daneke earned 2000 total points
ID: 40267438
control - tab is the sequence you want.  Alt-tab changes to another program.   Control-tab changes to another workbook that is already open and you stay in Excel.

You can do this with a VBA command
    ActiveWindow.ActivateNext

Open in new window

0
 

Author Closing Comment

by:RWayneH
ID: 40272936
Nailed it!!  Thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question