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

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

Sub SaveWithNewName()

    Dim NewFN As Variant


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

    ActiveWorkbook.SaveAs NewFN, FileFormat:=52



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...."



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.

Did this solve your problem?

Sorry this didn't help.

4 people were helped by this reply

Question Info

Views: 982 Last updated: June 22, 2018 Applies to: