• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 634
  • Last Modified:

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

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
macrohappy
Asked:
macrohappy
  • 6
  • 6
1 Solution
 
nutschCommented:
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
 
macrohappyAuthor Commented:
The window is Activating but "%{F4}", True is not closing it
0
 
nutschCommented:
Is there a keyboard shortcut in that app to close it, apart from Alt + F4?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
macrohappyAuthor Commented:
No under FILE it just says SAVE or EXIT, no PF keys for shortcuts
0
 
nutschCommented:
what program is it? And how do you access it if it's a non-windows application.

Thomas
0
 
macrohappyAuthor Commented:
it is an internal application and it is opened with a executable file. no different than you would open Quicken for example
0
 
nutschCommented:
if you right-click the app on the task bar, I assume you have the restore, minimize, close Alt+F4 options?
0
 
macrohappyAuthor Commented:
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
 
nutschCommented:
Are you running the macro with the wait or the one without?
How do you run it? Straight or step into?

T
0
 
macrohappyAuthor Commented:
ran it both ways, with the wait and without. I have been stepping into the macro
0
 
macrohappyAuthor Commented:
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
 
nutschCommented:
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's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 6
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now