VBA save sheet as pdf with specified name in a specified folder

tdavis95

New Member
Joined
Feb 24, 2022
Messages
7
Office Version
  1. 2016
Platform
  1. Windows
Hello.

So I am trying to create a macro that when the button on the sheet is pressed that specific sheet (not the whole workbook) will save as a pdf with the name "Initial Delivery Check dd-mm-yyyy hh-mm-ss"
I am not sure how to add the date and time to the name. I want the sheet to save as a new name each time so it does not override the previous copy. My current set up doesn't have date and time in the name so it just overwrites the previous version. I have looked through a lot of other examples and I can never get it to quite work for my set up.

My current VBA Code:

Sub CreatePDFSheet()
Sheet1.ExportAsFixedFormat xlTypePDF, Environ("Userprofile") & "\INSERT COMPANY FOLDERS HERE\Forms\Completed Forms\Initial Delivery Check.pdf"
End Sub
 
add another line above that which reads:
msgbox Range("B6").value

to see what value is showing up.
 
Upvote 0

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Also, make sure your value in B6 does NOT contain any characters that are invalid for filenames...
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,326
Members
452,635
Latest member
laura12345

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