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