how to Save As Pdf & Name From Cell with macro code

July 23, 2014 at 06:25:07
Specs: Windows 7
Sub Macro7()
'
' Macro7 Macro
'

'
Sheets("Form 16").Select
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\Rajesh\Desktop\Form 16 FY 2013 - 2014 Testing 1.pdf", Quality:= _
xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub


i required to save the pdf file with the specific cell like (A21), i:e A21 text will be the my pdf file name , please help

message edited by Rajeshindium


See More: how to Save As Pdf & Name From Cell with macro code

Report •


#1
July 23, 2014 at 12:46:28
First, a posting tip... if you click on the blue line at the bottom of this post, you can read the instructions on how to post VBA code in this forum so that the format is retained.

As for your question, try the following code.

Note: I am assuming that A21 does not contain the .pdf extension. If it does, you should be able to see how the file name was built by the code and modify it to work.

Sub SaveAsPDF()
Dim Fname As String
 myFname = Sheets("Form 16").Range("A21")
   Sheets("Form 16").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
   "C:\Users\Rajesh\Desktop\" & myFname & ".pdf", Quality:= _
   xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _
   OpenAfterPublish:=True
End Sub

Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.


Report •

#2
July 24, 2014 at 05:46:59
Thank You so much Derby Dab ,
it's really helpful thanks thanks

Report •
Related Solutions


Ask Question