Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88050

Exporting .xlsx and .pdf where filename already exists

$
0
0

I need some basic help that I can't get right in my code.

Saving as both an .xlsx and PDF file, in the same location, just can't get it to prompt if filename already exists

Sub SaveAs()
Dim Path As String
Dim filename As String
Path = "C:\Users\yard\Dropbox\Modus\Purchase Orders\"
filename = Range("E4")
            Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs filename:=Path & filename & ".xls", FileFormat:=xlOpenXMLWorkbook

    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:=Path & filename & ".pdf", Quality:= _
        xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
        OpenAfterPublish:=True

End Sub

Or have I cancelled that out by using Application.DisplayAlerts = False?

I don't want to be prompted regarding a macro enabled workbook when saving the excel file, however I would like it to prompt if the filename already exists.


Viewing all articles
Browse latest Browse all 88050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>