VBA code to switch to other application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I making an application in Excel that copies the content of a range to any
other running application on the computer, as can be done by a manual
copy/paste action.
However I want to automate the alt-tab key command (for switching to the
former application). What is the propriate VBA code for this action?

Thanks in advance,

Jan Bart
 
You can use the Create.Object command from Excel to open another application
such as Word, e.g.

Dim oApp As Object
Set oApp = CreateObject("Word.Application")
Set oDoc = oApp.documents.New
oApp.Visible = True


JM
 
Dear JM,

I only would like to switch to an already open application that I would also
get when I use the Alt-tab key command.

Regards,

Jan Bart
 
I don't think you can do that from excel, as Excel can only control an
instance of an application that it has created itself. If you want to
control already-open applications, you would need to write a Windows
Application.
 
If it is constantly the same app you're switching to you can use the
AppActivate statement.
For example:

appactivate "Microsoft Word"
appactivate thisworkbook.name (to switch back)
 
Well, I am using AppActivate to send data to "Exact voor Windows"
(accounting software) combined with SendKeys. Works fine.
Within Win2K and Excel2K that is, pls see my other post.
 
Back
Top