AppActivate works in Excel 2007 but not in 2010

RShome picture RShome · Oct 25, 2017 · Viewed 7.7k times · Source

I have a excel macro that I run in Excel 2007 and it opens a mainframe application so I can import data from my spreadsheet automatically.

This has been working fine, however it doesn't work in Excel 2010.

I have tried using the shell command to use the ID but the other application is a mainframe application and non windows based.

However,

AppActivate "Title" (to open the mainframe application) was working fine in excel 2007.

In Excel 2010 I am getting a Run-time error 5 - Invalid procedure call or argument.

I've been trying to solve this for two days and it all works fine on 2007 version.

Any help would be really appreciated.

Dim appName as String

appName = Range("AppName").Value 'this is a name stored in my excel spreadsheet for the mainframe app

AppActivate (appName) => this line is giving runtime error '5' invalid procedure call or argument

Answer

Shai Rado picture Shai Rado · Oct 25, 2017

If you want to return the focus back to the Excel where your VBC code lies, aka ThisWorkbook object, then you can use the following line:

AppActivate Title:=ThisWorkbook.Application.Caption