Simulate ALT+TAB in Excel macro

Is there a send.keys command to simulate the press of ALT+TAB, to get to what the previous session was.
RWayneHAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aikimarkCommented:
    AppActivate "window caption text"   'may be optional
    SendKeys "%{TAB}", True

Open in new window

0
RWayneHAuthor Commented:
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
aikimarkCommented:
You can not step through such code.  How are you launching the routine?

Is the other (prior focus) window also an Excel workbook?
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

RWayneHAuthor Commented:
Yes the prior focus is an Excel workbook and when I step through it, it does not do anything.
0
aikimarkCommented:
what is the purpose of the focus change from one workbook to another?
0
RWayneHAuthor Commented:
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
aikimarkCommented:
It would be better to automate the import, where the VBA code iterates the workbooks.
0
NorieVBA ExpertCommented:
Where are the files saved?
0
Richard DanekeTrainerCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RWayneHAuthor Commented:
Nailed it!!  Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.