Share via

Excel 2016 VBA Run-time error '1004': Your changes could not be saved...

Anonymous
2016-02-01T21:21:51+00:00

Can anybody help me debug this line in the Macro I'm trying to do please,

Sub SaveWithNewName()

Dim NewFN As Variant

    ActiveSheet.Copy

    NewFN = "Users/gozmani/Desktop/IG Networks LTD/Inv" & Range("F4").Value & ".xlsx"

ActiveWorkbook.SaveAs NewFN, FileFormat:=52

    ActiveWorkbook.Close

    NextInvoice

End Sub

I tried different file format codes but can't make it work, I get the Error 1004 message "Your changes could not be saved to 'Inv2091.xlsx', but were saved to a temporary document...."

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Anonymous
    2017-04-26T16:59:58+00:00

    This doesn't solve my problem. Having the same as above listed.

    I'm using ActiveWorkbook.Path & Application.PathSeparator & NewFilename to build my string for executing

    ActiveWorkbook.SaveAs Filename:=FilenameStr, FileFormat:=xlCSV

    and it just gives 1004 errors.

    ...

    So, I instead went and Recorded the macro and performed the action. Other than putting the Path and filename explicitly in single quotes, the code was nearly the same. I replaced my variable FilenameStr in to the command and then it worked. The only other difference was that it split the command into two lines and appended them with _

    I think this is a bug.

    4 people found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2016-02-01T22:40:10+00:00

    Try:

    NewFN = "Users:gozmani:Desktop:IG Networks LTD:Inv" & Range("F4").Value & ".xlsx"

    And, you probably need to prefix the name of your hard drive, probably Macintosh HD:Users:gozmani etc..

    1 person found this answer helpful.
    0 comments No comments