Run time error 1004 - cannot save file this workbook with the same name

bks11

New Member
Joined
Aug 27, 2015
Messages
2
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.


Code:
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:
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Ok - I figured it out. Silly me had the original source document as the same name as I was trying to rename the new file to. Some days!
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,691
Members
449,117
Latest member
Aaagu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top