closing an external application from excel

piero1975

Board Regular
Joined
Nov 20, 2002
Messages
56
hi,
is there any mode for closing an external application from vb excel?
In particular, i've opened a acrobat file (with command Set app = CreateObject("AcroExCh.App") ), in which i fill some field data; then i need to save it and close it whitout it displays any message (do you want to save..etc). If I had a excel application, i know that commands like "application.displayalerts = false" or "application.displaynoteindicator=false" suits me well, but working with an external (such as acrobat) is not so easy, i think.
do you have any suggestion?
Thank a lot
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Hi Pierro;

I've opened a PDF file named AcrobatDoc.pdf
When I opened this pdf file, the caption of the pdf window is :

Acrobat Reader - [AcrobatDoc.pdf]

So, by using this string in the caption of the pdf window (which should be exactly as seen on the caption), I used an Api call to find and close the pdf window.

The related code is;

Code:
Declare Function FindWindow _
    Lib "user32" Alias "FindWindowA" ( _
    ByVal lpClassName As String, _
    ByVal lpWindowName As String) As Long

Declare Function PostMessage _
    Lib "user32" Alias "PostMessageA" ( _
    ByVal hwnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    ByVal lParam As Long) As Long
'
Sub ClosePDF()
Call PostMessage(FindWindow(vbNullString, "Acrobat Reader - [AcrobatDoc.pdf]"), _
    16, 0, 0)
End Sub
 
Upvote 0
You could always use SendKeys as below

Code:
Sub CloseApplication()
    AppActivate "Acrobat Reader - [AcrobatDoc.pdf]"  'Application title
    Application.Wait Now() + TimeSerial(0, 0, 1) 'Wait 1 second
    SendKeys "^q"  'CTRL + Q
End Sub


I use sendkeys alot and they work very nicely[/code]
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,698
Members
448,979
Latest member
DET4492

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top