![download excel 2016 vba documentation download excel 2016 vba documentation](https://isacann.com/images/excel-userform-tutorial-pdf-3.png)
The name of the active sheet is cleaned up - spaces are removed, and periods are replaced with underscores. If the active workbook has not been saved, Excel's default save folder is used. If the active workbook has been saved, its path is used.
Download excel 2016 vba documentation pdf#
Next, the macro gets the default path for saving the PDF file. Otherwise, Excel would interpret the underscore as the spacing character that is used in Excel number formatting.
![download excel 2016 vba documentation download excel 2016 vba documentation](https://tutsgalaxy.net/wp-content/uploads/2020/06/Unlock-Excel-VBA-And-Excel-Macros.jpg)
In the format string shown below, a backslash is entered before the underscore, to indicate it is a literal character. Set wbA = ActiveWorkbookĪ time stamp will be added to the default name, in the format yyyymmdd_hhmm. Those will be used to set the default file name and folder. When the macro starts, it sets variables for the active sheet, and the active workbook. Title:="Select Folder and FileName to save")īefore you run the macro, select the sheet(s) that you want to export to the PDF file. StrFile = strName & "_" & strTime & ".pdf"įileFilter:="PDF Files (*.pdf), *.pdf", _ 'replace spaces and periods in sheet name StrTime = Format(Now(), "yyyymmdd\_hhmm") Create PDF file with name from worksheet cells - check for existing file, prompt to overwrite or choose different nameĬopy the following VBA code to a regular code module, then select the sheet(s) you want to export, and run the macro.Create PDF file with name from worksheet cells - automatically overwrites existing file, if any.NOTE: There are two additional macros below: See the section further down, for details on how the macro works. Copy the code to a regular code module, then select the sheet(s) you want to export, and run the macro.
![download excel 2016 vba documentation download excel 2016 vba documentation](http://fasrer296.weebly.com/uploads/1/2/5/0/125041769/775921829.png)
The following macro code will export the active sheet (or sheets) in PDF format. More Tutorials Export Active Sheet as PDF File