title: Run-time error '1004': Method SaveAs of object _Workbook failed
body: <p>I'm writing a program that saves a workbook to a specific folder based on some cell values in the workbook. Everything works as it should until I get to the ActiveWorkbook.SaveAs line, where I get a Run-time error 1004. </p>
  
  <p>`Sub Tester()</p>
  
  <pre><code>Dim qNum, fldr As String
  Dim custName As String
  Dim myFileName As String
  Dim completePath As String
  Dim division As String
  
  custName = Range("B12").Value
  qNum = Range("B19").Value
  
  If custName = "CNUL - Albian" Then
      custName = "CNRL"
      division = "Albian"
  End If
  If custName = "CNUL - Horizon" Then
      custName = "CNRL"
      division = "Horizon"
  End If
  If custName = "CNRL - Albian" Then
      custName = "CNRL"
      division = "Albian"
  End If
  If custName = "CNRL - Horizon" Then
      custName = "CNRL"
      division = "Horizon"
  End If
  
  If custName = "CNRL" Then
      fldr = GetMatchingPathCNRL(qNum, custName, division) '&lt;&lt; find the        matching folder
      If Len(fldr) &gt; 0 Then
          Debug.Print "Found folder for customer=" &amp; custName &amp; _
                          ", Qnum=" &amp; qNum &amp; vbLf &amp; fldr
              '...use this path
  
      Else
          MsgBox "No matching folder!", vbExclamation
      End If
  Else
      fldr = GetMatchingPath(qNum, custName) '&lt;&lt; find the matching folder
      If Len(fldr) &gt; 0 Then
          Debug.Print "Found folder for customer=" &amp; custName &amp; _
                      ", Qnum=" &amp; qNum &amp; vbLf &amp; fldr
          '...use this path
  
      Else
          MsgBox "No matching folder!", vbExclamation
      End If
  End If
  
  
  myFileName = custName &amp; " " &amp; qNum &amp; " " &amp; "MTO Rev A"
  completePath = fldr &amp; "\" &amp; myFileName
  
  ActiveWorkbook.SaveAs Filename:=completePath
  End Sub
  
  Function GetMatchingPath(qNum, custName) As String
  Const ROOT As String = "P:\MyCompany\" '&lt;&lt; adjust to suit
  Dim f
  f = Dir(ROOT &amp; custName &amp; "\*" &amp; qNum &amp; "*", vbDirectory)
  GetMatchingPath = ROOT &amp; custName &amp; "\" &amp; f
  End Function
  
  
  Function GetMatchingPathCNRL(qNum, custName, division) As String
  Const ROOT As String = "P:\MyCompany\" '&lt;&lt; adjust to suit
  Dim f
  f = Dir(ROOT &amp; custName &amp; "\" &amp; division &amp; "\*" &amp; qNum &amp; "*", vbDirectory)
  GetMatchingPathCNRL = ROOT &amp; custName &amp; "\" &amp; f
  End Function
  </code></pre>
  
  <p>`
  The idea is that if the customer is CNRL there is an extra layer of folders to go through. The 4 'if' statements at the beginning are just to navigate a few different ways people may enter information into the spreadsheet. </p>
  
  <p>I am always getting a 1004 error when it gets to the save file line, but the variables are all storing the correct names and folder paths. Any ideas?</p>