+ Reply to Thread
Results 1 to 2 of 2

Save As PDF And (please do not) Overwrite Existing

Hybrid View

  1. #1
    Registered User
    Join Date
    10-14-2016
    Location
    Turkey
    MS-Off Ver
    2016
    Posts
    12

    Save As PDF And (please do not) Overwrite Existing

    Any help appreciated!

    When saving .xlsx files with the command ActiveWorkbook.SaveAs I get waning that says the file already exist.

    But the codes below which prints the pdf file to specified folder, it overwrites every time.
    How can I get notified that there is already existing file?

      Dim PdfFileName As String
      Dim Wsheet As String
      
      PdfFileName = Range("P1").Value & "  " & Range("H11").Text & "  " & Range("H12").Text & "  " & Range("C12").Value
      Wsheet = ActiveSheet.Name
      
      ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
      "C:\Users\cangokturk\Desktop\Invoices\" & PdfFileName & ".pdf", _
      Quality:=xlQualityStandard, _
      IncludeDocProperties:=True, _
      IgnorePrintAreas:=False, OpenAfterPublish:=True
    Cheers!

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    45,074

    Re: Save As PDF And (please do not) Overwrite Existing

    Use the Dir command to check if the file exists.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ 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. Overwrite existing cells
    By Mulberry in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-13-2015, 11:57 PM
  2. Overwrite existing directory
    By bberger1985 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-27-2013, 06:28 PM
  3. Overwrite existing record
    By bryan1706 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-09-2012, 11:15 AM
  4. Save As-Overwrite existing File
    By loulorisgomez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2012, 07:24 AM
  5. [SOLVED] Macro with "save as" --- Need excel to overwrite a file without a prompt to overwrite
    By tsmith1 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-21-2012, 10:54 AM
  6. Overwrite existing data
    By kishoremcp in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-21-2012, 09:10 PM
  7. Overwrite existing excel sheets
    By med1234 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-18-2011, 03:36 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