+ Reply to Thread
Results 1 to 4 of 4

Macro to Save file as PDF with Error to stop if name already exists

  1. #1
    Registered User
    Join Date
    04-17-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    7

    Macro to Save file as PDF with Error to stop if name already exists

    Hi,

    Please could someone help with the attached excel form I have created. I have the VBA Code to save the form as a PDF using cell C5 as the reference cell. The code works apart from the error, it keeps re-saving over the original file. Could someone tell me how I add the date and time into cell C5 so that it becomes unique everytime and then the error code isn't required. I have tried Concatenating Cell C2 into C5, but this generates a huge number. I would like the name to still be readable. Or if someone can look at the code and tell me how I get the error code working, so that if the name exists already the VBA code adds "_1" onto the end then "_2" etc.

    Thank you in advance for your help
    Attached Files Attached Files

  2. #2
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Macro to Save file as PDF with Error to stop if name already exists

    Try adding a workbook with your code in it :-)

  3. #3
    Registered User
    Join Date
    04-17-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Macro to Save file as PDF with Error to stop if name already exists

    Sorry wrong file attached : please see this file.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    04-17-2013
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Macro to Save file as PDF with Error to stop if name already exists

    Figured it out just need to add
    Format(Now, "ddmmyyyy--hhmm")

    to the file name

+ 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