Forum Discussion

pedrohrmoreira's avatar
pedrohrmoreira
Copper Contributor
Jun 17, 2020

Run-time '1004' Save

Hi all,

 

I'm having some issues with a Save As macro I'm trying to run. It is exactly the same code I use for a separate report (which works fine), however, on this one, I seem to continuously get the following message:

 

"Run-time error '1004': Method 'SaveAs' of object '_Workbook' failed

 

I'm struggling to see what I am doing wrong in the code - can somebody please advise? The code should instruct it to save as per the specified strings. Code as below:

 

 

Many thanks,

Pedro M.

 

3 Replies

  • pedrohrmoreira 

     

    You should declare a String variable to hold the dynamic file name and assign dynamic file name to this variable and use debug.print to print the variable in the Immediate Window and see if the filename is a valid file name.

     

    Dim strFileName As String

    strFileName = strgenericfilepath & strpackingbranch & stryear & strmonth & strday & strfilename

    Debug.Print strFileName

    'SaveAs statement here

Resources