+ Reply to Thread
Results 1 to 2 of 2

VBA to Promt if PDF exists and to overwrite - Close Existing File first

  1. #1
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    VBA to Promt if PDF exists and to overwrite - Close Existing File first

    I have an Excel sheet that I convert to PDF --here is Example of the name after PDF creates"Morning Report_08.16.14" , When it runs it just overwrites the file automatically if one was already on that date - I would like it to prompt to overwrite & if they choose 'yes' to overwrite the file and if not they can change the name If the new one is in addition to the one that already exists and I want it to save the new file with in the same folder.

    Also when the current code is run if the PDF was left opened it stops the macro - Is it possible to see if that file is open and if so close it down so the code will work or is it possible to overwrite the file when open.

    Please Login or Register  to view this content.
    Last edited by bdouglas1011; 08-17-2014 at 12:51 AM. Reason: Removed extra code

  2. #2
    Forum Expert
    Join Date
    07-15-2012
    Location
    Leghorn, Italy
    MS-Off Ver
    Excel 2010
    Posts
    3,431

    Re: VBA to Promt if PDF exists and to overwrite - Close Existing File first

    Please Login or Register  to view this content.
    If solved remember to mark Thread as solved

  3. #3
    Forum Contributor
    Join Date
    10-02-2013
    Location
    Houston, TX
    MS-Off Ver
    office 365
    Posts
    638

    Re: VBA to Promt if PDF exists and to overwrite - Close Existing File first

    That worked great, thank You How would I add that if they choose to hit cancel then it cancels? Right now if they do anything else beside enter "Y" it makes new file...Can it be modified to just be "yes" "no" "Cancel" - anything other than that gives message you must choose Y,N or Cancel.

    Yes = Overwrite file / No = Makes the new time stamped file / Cancel = Exits entirely.

    Also

    Is it possible that after it knows the file exists and it prompts if you want to overwrite & if you choose overwrite then it makes sure the PDF is closed so it can overwrite

    Right now you get a runtime error and the procedure stops until the user manually closes the file.

    Maybe If it cant close automatically then it would prompt a different box saying that "the PDF seams to be open can not overwrite please close PDF and rerun." then exit

    That way they would not get the run-time error saying could not save.....
    Last edited by bdouglas1011; 08-17-2014 at 05:35 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Stop overwrite of file if it already exists, no popup wanted
    By LoneWolf3574 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-06-2012, 07:24 AM
  2. Save As-Overwrite existing File
    By loulorisgomez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2012, 07:24 AM
  3. Prevent overwrite of existing file when saving as pdf
    By glenin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-16-2010, 06:04 PM
  4. Export And Overwrite Existing file
    By okelly in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-20-2007, 11:19 AM
  5. accidentally click YES to overwrite an existing file
    By mtrent in forum Excel General
    Replies: 2
    Last Post: 03-30-2006, 02:10 PM

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