Method saveas of object _workbook failed” error while trying to save an XLSM file

kowal090

New Member
Joined
Jun 8, 2015
Messages
1
I have master workbook ‘WORK ORDER.xlsm’.with few worksheets (Main, Summary 14 days, Invoice, Data). My employees filling up ‘Summary 14 days’ sheet every day and in the end pressing button with vba code. My intension was to save workbook (always same company network folder) with different name and actual invoice number, clear ‘Summary 14 days’ sheet and increase invoice number.
Sometimes, but not always, it fails and there is a error message (Runtime Error 1004: method saveas of object _workbook failed) pops out with the debugger pointing me out this row:

ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook

Also it takes at least 2 minutes to run the code. Any suggestions how to improve this code. I am using Office 2011 for Mac and all employees Office 365 for Windows). Thank you in advance.


Sub NextInvoice()
Range("'Summary 14 days'!Q3").Value = Range("'Summary 14 days'!Q3").Value + 1
Range("'Summary 14 days'!C9:'Summary 14 days'!G16").ClearContents
Range("'Summary 14 days'!B59:'Summary 14 days'!B66").ClearContents
Range("'Summary 14 days'!B101:'Summary 14 days'!B106").ClearContents
Range("'Summary 14 days'!B127:'Summary 14 days'!B134").ClearContents
Range("'Summary 14 days'!B139:'Summary 14 days'!B146").ClearContents
Range("'Summary 14 days'!B153:'Summary 14 days'!B154").ClearContents
Range("'Summary 14 days'!D21:'Summary 14 days'!Q23").ClearContents
Range("'Summary 14 days'!D25:'Summary 14 days'!Q25").ClearContents
Range("'Summary 14 days'!D27:'Summary 14 days'!Q27").ClearContents
Range("'Summary 14 days'!D29:'Summary 14 days'!Q29").ClearContents
Range("'Summary 14 days'!D31:'Summary 14 days'!Q31").ClearContents
Range("'Summary 14 days'!D33:'Summary 14 days'!Q33").ClearContents
Range("'Summary 14 days'!D35:'Summary 14 days'!Q35").ClearContents
Range("'Summary 14 days'!D37:'Summary 14 days'!Q37").ClearContents
Range("'Summary 14 days'!D39:'Summary 14 days'!Q39").ClearContents
Range("'Summary 14 days'!D41:'Summary 14 days'!Q41").ClearContents
Range("'Summary 14 days'!D43:'Summary 14 days'!Q43").ClearContents
Range("'Summary 14 days'!D45:'Summary 14 days'!Q45").ClearContents
Range("'Summary 14 days'!D47:'Summary 14 days'!Q47").ClearContents
Range("'Summary 14 days'!D49:'Summary 14 days'!Q49").ClearContents
Range("'Summary 14 days'!D51:'Summary 14 days'!Q51").ClearContents
Range("'Summary 14 days'!D53:'Summary 14 days'!Q53").ClearContents
Range("'Summary 14 days'!D55:'Summary 14 days'!Q55").ClearContents
Range("'Summary 14 days'!D57:'Summary 14 days'!Q57").ClearContents
Range("'Summary 14 days'!D59:'Summary 14 days'!Q59").ClearContents
Range("'Summary 14 days'!D61:'Summary 14 days'!Q61").ClearContents
Range("'Summary 14 days'!D63:'Summary 14 days'!Q63").ClearContents
Range("'Summary 14 days'!D65:'Summary 14 days'!Q65").ClearContents
Range("'Summary 14 days'!D71:'Summary 14 days'!Q71").ClearContents
Range("'Summary 14 days'!D73:'Summary 14 days'!Q73").ClearContents
Range("'Summary 14 days'!D75:'Summary 14 days'!Q75").ClearContents
Range("'Summary 14 days'!D77:'Summary 14 days'!Q77").ClearContents
Range("'Summary 14 days'!D79:'Summary 14 days'!Q79").ClearContents
Range("'Summary 14 days'!D81:'Summary 14 days'!Q81").ClearContents
Range("'Summary 14 days'!D83:'Summary 14 days'!Q83").ClearContents
Range("'Summary 14 days'!D85:'Summary 14 days'!Q85").ClearContents
Range("'Summary 14 days'!D87:'Summary 14 days'!Q87").ClearContents
Range("'Summary 14 days'!D89:'Summary 14 days'!Q89").ClearContents
Range("'Summary 14 days'!D91:'Summary 14 days'!Q91").ClearContents
Range("'Summary 14 days'!D93:'Summary 14 days'!Q93").ClearContents
Range("'Summary 14 days'!D95:'Summary 14 days'!Q95").ClearContents
Range("'Summary 14 days'!D97:'Summary 14 days'!Q97").ClearContents
Range("'Summary 14 days'!D99:'Summary 14 days'!Q99").ClearContents
Range("'Summary 14 days'!D101:'Summary 14 days'!Q101").ClearContents
Range("'Summary 14 days'!D103:'Summary 14 days'!Q103").ClearContents
Range("'Summary 14 days'!D105:'Summary 14 days'!Q105").ClearContents
Range("'Summary 14 days'!D111:'Summary 14 days'!Q111").ClearContents
Range("'Summary 14 days'!D113:'Summary 14 days'!Q113").ClearContents
Range("'Summary 14 days'!D115:'Summary 14 days'!Q115").ClearContents
Range("'Summary 14 days'!D117:'Summary 14 days'!Q117").ClearContents
Range("'Summary 14 days'!D119:'Summary 14 days'!Q119").ClearContents
Range("'Summary 14 days'!D121:'Summary 14 days'!Q121").ClearContents
Range("'Summary 14 days'!D123:'Summary 14 days'!Q123").ClearContents
Range("'Summary 14 days'!D125:'Summary 14 days'!Q125").ClearContents
Range("'Summary 14 days'!D127:'Summary 14 days'!Q127").ClearContents
Range("'Summary 14 days'!D129:'Summary 14 days'!Q129").ClearContents
Range("'Summary 14 days'!D131:'Summary 14 days'!Q131").ClearContents
Range("'Summary 14 days'!D133:'Summary 14 days'!Q133").ClearContents
Range("'Summary 14 days'!D139:'Summary 14 days'!Q139").ClearContents
Range("'Summary 14 days'!D141:'Summary 14 days'!Q141").ClearContents
Range("'Summary 14 days'!D143:'Summary 14 days'!Q143").ClearContents
Range("'Summary 14 days'!D145:'Summary 14 days'!Q145").ClearContents
Range("'Summary 14 days'!D151:'Summary 14 days'!Q151").ClearContents
Range("'Summary 14 days'!D153:'Summary 14 days'!Q153").ClearContents
Range("'Summary 14 days'!C175:'Summary 14 days'!Q202").ClearContents
End Sub

Sub SaveInvoice()
Dim NewFN As Variant
ActiveWorkbook.Sheets.Copy
NewFN = " N:\Network\WORK ORDERS\WR" & Range("'Summary 14 days'!Q3").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
NextInvoice
Workbooks("WORK ORDER.xlsm").Save
Workbooks("WORK ORDER.xlsm").Close
End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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