im new to excel so i hope i explain this well
i have a workbook with 2 sheets one is named " Contract ' and one is named " Input " so i wrote a code for a button that is in the Input sheet that will print the contents of the " Contract " sheet as pdf, the code worked but when i try to change the file name it wont work
what is was trying to do was that i wanted the file name to be the value of a cell in the " Input " sheet
----------------------------------------------------------------------------------------
the code that worked :
----------------------------------------------------------------------------------------
Sub CommandButton1_Click()
Dim PrintFile As String
PrintFile = Application.DefaultFilePath & "" & _
ActiveWorkbook.Name & ".pdf"
Sheets("Contract").Select
ActiveSheet.PageSetup.PrintArea = "G1:X124"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=PrintFile, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub
----------------------------------------------------------------------------------------
the code that wont work:
----------------------------------------------------------------------------------------
Sub CommandButton1_Click()
Dim PrintFile As String
PrintFile = Range("K24").Value & ".pdf"
Sheets("Contract").Select
ActiveSheet.PageSetup.PrintArea = "G1:X124"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=PrintFile, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End Sub
Bookmarks