Hello,

I'm trying to save a file to a specified folder with a custom filename depending on the contents of certain cells.

Everything used to work fine, however suddenly I got Runtime error 1004: the specified dimension is not valid for the current chart type whenever the macro gets to the save-routine.

Code looks as follows:

To generate the filename:
Private Sub NameFile()
    Dim fname As String
    Dim strFileN As String
    Dim namescrubbed As String
    fname = Range("artikelnr").Text & "-" & Range("fichenr").Text & "-" & Format(Now, "yyyymmdd") & "-" & Range("Ploegnaam").Text & "-grafctrl"
    strFileN = fname 
    
    If (IsLegalFileName(strFileN)) Then
       namescrubbed = strFileN & ".xlsm"
    ElseIf Not IsLegalFileName(strFileN) Then
      namescrubbed = ScrubFileName(strFileN) & ".xlsm"
    End If
    
    fileSaveName = "\\filesrv\saved\" & namescrubbed 
End Sub
And then to save the file:

If fileSaveName <> "" Then
          Application.DisplayAlerts = False
          ActiveWorkbook.SaveAs fileSaveName, FileFormat:=xlOpenXMLWorkbookMacroEnabled
          Application.DisplayAlerts = True
End If
The code chokes at ActiveWorkbook.SaveAs fileSaveName, FileFormat:=xlOpenXMLWorkbookMacroEnabled.

Does anyone have any idea what may cause this problem? Note that a chart appears in the worksheet, but I don't refer to it anywhere in the code...