title: VBA Error: "Compile error: Expected End Sub"
body: <p>Trying to pass "GetFullNamePDF()" to the Filename attribute, but getting the following error: "Compile error: Expected End Sub"</p>
  
  <pre><code>Sub PrintPDF()
  
      Function GetFullNamePDF() As String
          GetFullNameCSV = Replace(ThisWorkbook.FullName, ".xlsm", ".pdf")
      End Function
  
      ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
          "GetFullNamePDF()", Quality:=xlQualityStandard, IncludeDocProperties _
          :=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
  
  End Sub
  </code></pre>
  
  <p>I know nothing about VBA, and got the above code from a <a href="https://stackoverflow.com/questions/4466998/in-excel-using-vba-how-do-i-take-the-pathfilenameextension-and-change-the-e">question I asked yesterday</a>, but was unable to test at the time. Guessing the error has to do with the function, since the code works without the function added and the filepath/name hard coded.</p>
  
  <p>Idea of the code is to dynamically use the filename of itself to name the path and file for the PDF. If you have any questions, just comment -- thanks!</p>