+ Reply to Thread
Results 1 to 9 of 9

close PDF file

  1. #1
    Registered User
    Join Date
    08-03-2012
    Location
    Qld, Australia
    MS-Off Ver
    Excel 2010
    Posts
    6

    close PDF file

    Hi. Does anyone know the code to close a PDF file? Thanks.
    Last edited by josh1981; 08-18-2012 at 06:42 AM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: close PDF file

    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 Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    08-03-2012
    Location
    Qld, Australia
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: close PDF file

    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.

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: close PDF file

    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.

  5. #5
    Registered User
    Join Date
    08-03-2012
    Location
    Qld, Australia
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: close PDF file

    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?

  6. #6
    Registered User
    Join Date
    08-03-2012
    Location
    Qld, Australia
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: close PDF file

    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.

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: close PDF file

    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.

  8. #8
    Registered User
    Join Date
    08-03-2012
    Location
    Qld, Australia
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: close PDF file

    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.

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: close PDF file

    Hello Josh,

    I forgot about that argument opening Acrobat when set to true. Good catch.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1