I have a macro that will switch between programs. I noticed that Excel 2010 and 2016 are named differently in the system (my semantics are wrong here, sorry!), And instead of changing the code depending on which Excel, I just thought I could use the variable to set , what.
Sub test() 'code here in Excel Dim myApp myApp = Application.Application AppActivate "Google Chrome" Call AppActivate("Google Chrome") ' do one or two things AppActivate myApp 'do more things in Excel End Sub
Unfortunately, AppActivate myApp does not work. He throws
Runtime Error '5': Incorrect procedure call or argument
Is there a way to do what I'm trying to do? I see on this site that I could do something like:
Public vPID As Variant vPID = Shell("C:\Windows\system32\notepad.exe", vbNormalFocus) AppActivate (vPID)
Also, what if Excel is not in the same file path on the two computers on which it will be used?
Edit: it looks like I just need to set the Application Title to a variable (again, from this site):
Typically, the AppActivate operator is used to activate an existing application based on its name.
edit2: Going closer, I found that I can get the path to Excel.Exe this, excelPath = Application.Path & "\Excel.exe" , but I canβt figure out what to call it.
source share