dominicwellsuk
New Member
- Joined
- Mar 23, 2011
- Messages
- 28
I'm trying to save all worksheets within a workbook as individual workbooks, and all was going well until I tried to introduce a unique filename based on cell B2 of each tab. Current code is:
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Copy
With ActiveWorkbook
UNIQUEREF = ActiveSheet.Range("B2")
.SaveAs Filename:="D:\" & UNIQUEREF & ".xls" 'Error Line
.Close
End With
Next ws
I get the error message: Method 'SaveAs' of object '_Workbook' failed
Any ideas how to resolve this? Thanks.
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Copy
With ActiveWorkbook
UNIQUEREF = ActiveSheet.Range("B2")
.SaveAs Filename:="D:\" & UNIQUEREF & ".xls" 'Error Line
.Close
End With
Next ws
I get the error message: Method 'SaveAs' of object '_Workbook' failed
Any ideas how to resolve this? Thanks.