• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Run-time error '1004' Not sure why? Code runs well in one place.

I have a macro that errors out on the line of code that says ActiveWorkbook.

The exact same code runs well in one place but not the other.

Any idea why?

Code:
sFileName = "MN Packout Log " & Format(Now, "mm-dd-yy") & ".xlsm"
  sBasePath = "C:\General Use\UPS Daily Tracking\Logs\"
 
  ActiveWorkbook.SaveAs sBasePath & sFileName
 
As said path is missing there!

Code:
Dim sFileName As String, sBasePath As String
sFileName = "MN Packout Log " & Format(Now, "mm-dd-yy") & ".xlsm"
  sBasePath = "C:\General Use\UPS Daily Tracking\Logs\"
    If Dir(sBasePath, vbDirectory) <> "" Then ActiveWorkbook.SaveAs sBasePath & sFileName Else MsgBox "Path Missing"
 
Back
Top