VBA to save a copy of the file as a PDF without changing the current filetype?

LucidCheetah

New Member
Joined
Dec 11, 2017
Messages
15
I have a button macro'd to save a daily backup of a spreadsheet we use daily at work. I would liek to save these historical backups as PDFs to avoid employees altering the data after the fact, but how can I do this without changing the current active file type or filename?

At the moment I have it saving the backup fiel to the directory with a dated filename, then just saving over the original file after to revert back to the original file. saving the historical copy as a PDF busts this. I feel liek there has got to be a better way to do it. Any tips?
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I'm not sure what you are referring to, but you can control what the PDF is saved as.

Change folder to suit...
VBA Code:
Sub Button1_Click()
    Dim s As String, folder As String

    folder = "C:\Users\dmorrison\Downloads\"
    s = ActiveSheet.Name & "-" & Format(Date, "mm dd yy")


    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
                                    Filename:=folder & s & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, _
                                    IgnorePrintAreas:=False, OpenAfterPublish:=True
    

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,836
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top