![visual basic for excel examples visual basic for excel examples](https://i.imgur.com/8bZnZwd.png)
XlSheet.Range(rngName).ExportAsFixedFormat Type:=xlTypePDF, Filename:=tmpFolderPath & "\" & tmpFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=showFile TmpFileName = "tmp" & Format(Now, "ddmmhhmmss") & ".pdf" Set xlSheet = ThisWorkbook.Worksheets(SOURCESHEET)
#VISUAL BASIC FOR EXCEL EXAMPLES PDF#
To generate PDF from Print Area we need to select the range and set print area as shown below:
![visual basic for excel examples visual basic for excel examples](https://i.ytimg.com/vi/4C6-5jIv3b8/maxresdefault.jpg)
![visual basic for excel examples visual basic for excel examples](https://www.excelacademy.it/wp-content/uploads/2020/06/Visual-Basic-Editor-1024x669.jpg)
ExportAsFixedFormat method allows to export specific Excel range into PDF format. Inside the New button’s code, add the following to complete the Excel object creation process: xlWorkBook xlApp.Visible True xlWorkSheet xlWorkBook.Sheets ('Sheet1') This instantiates an Excel Application object, adds a new Workbook, and specifies the Worksheet we will be working on.