Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-11-16
12
Medium Priority
?
617 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

618 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