Solved

In VBA how can I activate a non windows/Microsoft application and the close it?

Posted on 2010-11-16
12
598 Views
Last Modified: 2012-05-10
In a Excel VBA program  how do I first  identify and activate a non-Windows/Microsoft application and them close it? The program does not need to be saved so even using the X would work
0
Comment
Question by:macrohappy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 39

Expert Comment

by:nutsch
ID: 34148175
You could do something like this

Public Sub ActivateAndClose()

AppActivate "In VBA how can I activate a non windows/Microsoft application and the close it? - Mozilla Firefox"
SendKeys "%{F4}", True
End Sub

Open in new window


Thomas


Public Sub GetSAP2()

AppActivate "In VBA how can I activate a non windows/Microsoft application and the close it? - Mozilla Firefox"
application.Wait DateAdd("s", 1, Now)
SendKeys "%{F4}", True
End Sub

Open in new window

0
 

Author Comment

by:macrohappy
ID: 34148234
The window is Activating but "%{F4}", True is not closing it
0
 
LVL 39

Expert Comment

by:nutsch
ID: 34148292
Is there a keyboard shortcut in that app to close it, apart from Alt + F4?
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

Author Comment

by:macrohappy
ID: 34148336
No under FILE it just says SAVE or EXIT, no PF keys for shortcuts
0
 
LVL 39

Expert Comment

by:nutsch
ID: 34148362
what program is it? And how do you access it if it's a non-windows application.

Thomas
0
 

Author Comment

by:macrohappy
ID: 34148397
it is an internal application and it is opened with a executable file. no different than you would open Quicken for example
0
 
LVL 39

Expert Comment

by:nutsch
ID: 34148517
if you right-click the app on the task bar, I assume you have the restore, minimize, close Alt+F4 options?
0
 

Author Comment

by:macrohappy
ID: 34148594
Yes, sorry forgot about that. One thing to note. The program comes to the front when activated but the task bar is not highlighted. Not sure if that makes a difference
0
 
LVL 39

Expert Comment

by:nutsch
ID: 34148650
Are you running the macro with the wait or the one without?
How do you run it? Straight or step into?

T
0
 

Author Comment

by:macrohappy
ID: 34148672
ran it both ways, with the wait and without. I have been stepping into the macro
0
 

Author Comment

by:macrohappy
ID: 34148781
OK, I just ran the macro without stepping through it. One problem I get a pop up asking if I want to exit. Buttons are OK and Cancel
0
 
LVL 39

Accepted Solution

by:
nutsch earned 500 total points
ID: 34149685
if the default is ok, then you can run the attached code.

If you step into, your appactivate is negated by the fact that the code has to reactivate the vb editor window to show you the steps.

Thomas
Public Sub ActivateAndClose()

AppActivate "In VBA how"
SendKeys "%{F4}", True 'send Alt+F4
application.Wait DateAdd("s", 1, Now)'wait 1 second for the popup
SendKeys "~", True 'send Enter

End Sub

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel vba question 7 39
Need transfer the format too ... 3 37
In Excel, select specific rows from a list and place in separate worksheets 9 39
Hash on Excel 13 38
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

763 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