VBA Run-time error '1004'

VygonDBA

New Member
Joined
Jun 1, 2012
Messages
16
Hi all,

I've created a form with three VBA functions actioned via 2 macro enabled buttons which when tested prior to going live and up until today worked perfectly however......now I'm getting the above run-time error with the following message when I click my macro enabled 'Save' button which refers to 'SaveCRNWithNewName' (see code below):

"Method 'SaveAs' of object '_workbook failed"

I'm using Excel 2010 with some users on Excel 2007. I'd really appreciate any help anyone can give as I'm quite green where VBA is concerned!

VBA I'm using is below:

Sub NextInvoice()
Range("F6").Value = Range("F6").Value + 1
Range("C13:F30").ClearContents
Range("C33").ClearContents
Range("E35").ClearContents
Range("C35").ClearContents
Range("C37").ClearContents
Range("C38").ClearContents
Range("B38").ClearContents
End Sub


Sub SaveCRNWithNewName()
Dim NewFN As Variant
'Copy sheet to a new workbook
ActiveSheet.Copy
NewFN = "\\vparknas\Public\WAREHOUSE\Good Receiving Forms\2015\CRN" & Range("F6").Value & ".xlsx"
'Save copied workbook with NewFN then close and move to next invoice number
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
NextInvoice
End Sub


Sub CloseCRN()
ActiveWorkbook.Save
Application.Quit

End Sub
 
Grrrrrrrrr! Can't believe it......someone added an 's' into the 'Good Receiving Forms' filepath, one letter difference in the filepath name - can't believe I missed it!

Many thanks for your help, sorry to be such a pleb!
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
You are welcome. I am just glad that we figured it all out!

A lot of times, what is helpful to step through the code line-by-line (using the F8 key). Then you can see which line it is bombing out on, and have an idea on where you want to focus your attention.
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,800
Members
449,468
Latest member
AGreen17

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