title: Define file name via macro
body: <p>I have the following piece of code to save a pdf file from an existing excel file.</p>
  
  <pre><code>Dim FSO As Object
  Dim s(1) As String
  Dim sNewFilePath As String
  
  Set FSO = CreateObject("Scripting.FileSystemObject")
  s(0) = ThisWorkbook.FullName
  
  If FSO.FileExists(s(0)) Then
      '//Change Excel Extension to PDF extension in FilePath
      s(1) = FSO.GetExtensionName(s(0))
      If s(1) &lt;&gt; "" Then
          s(1) = "." &amp; s(1)
          sNewFilePath = Replace(s(0), s(1), ".pdf")
  
          '//Export to PDF with new File Path
          ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF,_
          _ Filename:=sNewFilePath, Quality:=xlQualityStandard,_
          _ IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
      End If
  Else
      '//Error: file path not found
      MsgBox "Error: this workbook may be unsaved.  Please save and try again."
  End If
  
  Set FSO = Nothing
  </code></pre>
  
  <p>Since the code has to be run recursively, I'd would like add to the file name the week number, contained in a given cell (B2) in the sheet.</p>
  
  <p>I tried replacing</p>
  
  <pre><code>s(0) = ThisWorkbook.FullName &amp; Cells(2,2)
  </code></pre>
  
  <p>but it is not working. Where is the error?</p>