Hi my name is Ronald and I'm a junior programmer. What I'm trying to do is when I click a button in workbook1 it starts a certain sub. In that sub, the application is supposed to copy a certain file, rename it, and open it. After that it has to call a sub of that new file with some parameters.

The problem is the following: Copying, renaming and opening the file is not a problem. But when I try to call the sub, the application gives the errormessage "400". I really don't know what the problem is, so if anyone has any idea, please tell me.

I'm using the following code:

filenameOriginal = ThisWorkbook.Path & "\invoice.xlsm"
    filename = "invoice " & client & "  " & Format(Now, "dd_mm_yyyy") & ".xlsm"
    filenameNew = ThisWorkbook.Path & "\" & filename
    
    'copy and open template
    FileCopy filenameOriginal, filenameNew
    Workbooks.Open (filenameNew)
    
    Application.Run "'" & filename & "'!fillInvoice", gegevens