View Single Post
 
Old 12-28-2019, 02:37 PM
LearnerExcel LearnerExcel is offline Windows 7 32bit Office 2013
Advanced Beginner
 
Join Date: Nov 2016
Posts: 81
LearnerExcel will become famous soon enoughLearnerExcel will become famous soon enough
Default Add file name automatically in the vba code ...

How can I add the file name automatically in the Excel VBA code?

ActiveSheet.Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$AE$40"
ActiveSheet.PageSetup.Orientation = xlPortrait
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="\\D:\MDH_Data\Delivery Notes\Print_DeliveryNote_001.pdf", Quality:=xlQualityStandard, IgnorePrintAreas:=False

Note: Print_DeliveryNote_001.pdf. This file name should be taken automatically from DeliveryNote.xlsx Cell "D4" and put in the below code line.
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:="\\D:\MDH_Data\Delivery Notes\Print_DeliveryNote_001.pdf", Quality:=xlQualityStandard, IgnorePrintAreas:=False
Reply With Quote