I have tried using the following solution to print from Excel to PDF:
Excel 2013 Print to PDF in VBA
While the solution seems to have worked for other people
Another cause of this error is if the filename contains illegal characters such as:
See 'Naming conventions' here: https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file
Solution: replace illegal characters with legal ones, such as '_'.