Excel VBA - How to Close a PDF File?
Posted on 2014-03-18
I would like to close a pdf file programmatically using Excel 2010 ( VBA ) regardless of the Adobe Program ( e.g. Adobe Reader, Adobe Acrobat, Adobe Acrobat Pro etc ) that is used to open the said file.
1. OS: windows 7, 8
2. the pdf file ( e.g. test1.pdf ) can be opened using any of the adobe programs - this depends on which program is installed in the machine
3. once the pdf file is open, it appears to be identified by its file name + adobe program i.e. test1.pdf - Adobe Reader
4. I am able to use the following code to close the file i.e.
AppActivate "test1.pdf - Adobe Reader"
In this example, I knew the pdf file is open using Adobe Reader.
a)How can I determine the full file name ( test1.pdf + whatever Adobe program ) so I can use AppActivate to capture the appropriate string value dynamically - at the point when the file is open programmatically ?
b) Is there a workaround to programmatically close the pdf file if route a is not possible ?