Hi. Does anyone know the code to close a PDF file? Thanks.
Hi. Does anyone know the code to close a PDF file? Thanks.
Last edited by josh1981; 08-18-2012 at 06:42 AM.
Hello josh1981,
Do you want to close the PDF file in Acrobat Reader or Acrobat Reader?
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
I suppose I would like to close acrobat reader.
---------- Post added at 11:51 AM ---------- Previous post was at 11:41 AM ----------
Here is the code bellow if it helps. It is to create a PDF file of the excel worksheet, then email the PDF file.
![]()
Please Login or Register to view this content.
Hello josh1981 ,
The code you posted only attaches a PDF file to the email. It does not open Acrobat Reader. If you want to close Acrobat Reader then copy the code below into a new VBA module. You can call "CloseAcrobatReader" from within your VBA code.
![]()
Please Login or Register to view this content.
Hi Leith. I ran the code and it did not do anything, so that would probably suggest that Acrobat Reader is not open as you have said. When my code opens the PDF file it has at the top bar Performance Report.pdf - Adobe Reader, so I assumed from that Acrobat Reader was open.
I used the macro recorder with excel 2010 to generate the PDF file if that helps.
Maybe it is the case that I just need the code to close the PDF file. Can you help with that?
Hi Leith. Your code does work on its own, however when I have called "CloseAcrobatReader" nothing happens. This is what I have got without the email code, with the code that you have given me in a seperate module:
![]()
Please Login or Register to view this content.
---------- Post added at 06:01 PM ---------- Previous post was at 05:58 PM ----------
Hi Leith. I put CloseAcrobatReader at the bottom of the code after the email code and it now closes the PDF file. Thanks very much for your help.
Hello josh1981,
Excel 2007 and later can create and read PDF files without opening Acrobat reader. The code you just posted will save the active sheet as a PDF but will not open Acrobat reader to do so. Unless Acrobat reader is open (you should see the icon on the taskbar), the macro will not do anything because it can not find a running instance of Acrobat Reader to close.
OK, after spending all day on this I have realised my mistake.
Change OpenAfterPublish:= _
True
To OpenAfterPublish:= _
False
This way the pdf file will not be opened.
Thanks for your help Leith, I am sure what you have given me will come in handy.
Hello Josh,
I forgot about that argument opening Acrobat when set to true. Good catch.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks