Joseph
Try this code:
Sub ShtToNewWkBk()
Dim fileName As String
fileName = "E:\MyNewFile.xls"
ThisWorkbook.ActiveSheet.Copy
ActiveWorkbook.SaveAs fileName
End Sub
It will copy the active sheet from the workbook in which the code is running and start
a new workbook consisting of only that sheet. The new book will be saved. You will need to amend the
filename etc to suit.
Any help?
Regards
Robb
Robb,
Thanks very much, this worked perfectly.
I have been unable to respond for a few days.
Would you be able to tell me what to add to make this new file read only?
Thanks again.
Joe.
Joseph
I have added the code you need to set the attributes of the new file to
read only. As you will notice, the file needs to be closed to do this or
it will result in an error. I like to specify file names, so I have amended
the variables to specify path and filename separately.
Sub ShtToNewWkBk()
Dim fileName As String, path As String
fileName = "MyNewFile.xls"
path = "E:\"
ThisWorkbook.ActiveSheet.Copy
ActiveWorkbook.SaveAs path & fileName
Workbooks(fileName).Close savechanges:=False
SetAttr path & fileName, vbReadOnly
End Sub
Hope this does the trick.
Regards
Robb
, Thanks very much, this worked perfectly.
Robb,
Thank you so much again.
This will help me greatly.
Hope to learn one day how to do these things myself.
I am sure that you will see my questions many times before that happens. This is a great site.
I have added the code you need to set the attributes of the new file to