I have been using this macro now for years and for some reason today is starting to throw this error. The macro takes a workbook and creates a new workbook for each worksheet, runs the macro "Customer Invoice" to format the file and then saves the file as the name of the worksheet plus the suffix of the date. At the step, ActiveWorkbook.SaveAs Filename:=NFName, _ FileFormat:=51, CreateBackup:=False ActiveWindow.Close, the error pops and stops the process. Previously we had been using this without issue on workbooks with close to 100 worksheets and all worksheets are confirmed to have unique names not exceeding 31 characters.
Sub BreakItUp()
Dim sht As Worksheet
Dim NFName As String
Const WBPath = "G:\Break\"
For Each sht In ActiveWorkbook.Worksheets
sht.Copy
NFName = WBPath & sht.Name & " 09.02.15.xlsx"
Application.Run "CustomerInvoice"
ActiveWorkbook.SaveAs Filename:=NFName, _
FileFormat:=51, CreateBackup:=False
ActiveWindow.Close
ActiveWorkbook.Close False
Next
End Sub
Code:
Dim sht As Worksheet
Dim NFName As String
Const WBPath = "G:\Break\"
For Each sht In ActiveWorkbook.Worksheets
sht.Copy
NFName = WBPath & sht.Name & " 09.02.15.xlsx"
Application.Run "CustomerInvoice"
ActiveWorkbook.SaveAs Filename:=NFName, _
FileFormat:=51, CreateBackup:=False
ActiveWindow.Close
ActiveWorkbook.Close False
Next
End Sub
Code: