Close Current File Then Open New file
I am trying to save and close the current .xls file the user is working on
then open a fresh unedited version of the file. I have the saving and closing working ok but since closing the document that is running the code stops everything, I can'd seem to get it to open the new file. Any ideas on how to accomplish this? Thanks Steve Private Sub btnSaveAndNew_Click() Dim FS As FileSystemObject Dim DT As Date Dim strProjectDescription As String Dim strProjectNumber As String Dim strProjectFolder As String Dim strInitials As String Dim strDate As String DT = Date strDate = Format(DT, "dd-mmm-yy") strProjectDescription = Range("c15") strProjectNumber = Range("H5") strProjectFolder = Replace(strProjectNumber, ".S.", "_") strInitials = GetInitials() Range("F5") = Date Range("C5") = strInitials ActiveWorkbook.SaveAs Filename:="G:\" & strProjectFolder & "\wp\" & strProjectFolder & " PS " & strDate & strInitials & ".xls" ActiveWorkbook.Close End Sub |
Close Current File Then Open New file
Steve,
Have you tried "SaveCopyAs" instead of "SaveAs" ? Regards, Jim Cone San Francisco, USA "Steve Roberts" wrote in message ... I am trying to save and close the current .xls file the user is working on then open a fresh unedited version of the file. I have the saving and closing working ok but since closing the document that is running the code stops everything, I can'd seem to get it to open the new file. Any ideas on how to accomplish this? Thanks Steve Private Sub btnSaveAndNew_Click() Dim FS As FileSystemObject Dim DT As Date Dim strProjectDescription As String Dim strProjectNumber As String Dim strProjectFolder As String Dim strInitials As String Dim strDate As String DT = Date strDate = Format(DT, "dd-mmm-yy") strProjectDescription = Range("c15") strProjectNumber = Range("H5") strProjectFolder = Replace(strProjectNumber, ".S.", "_") strInitials = GetInitials() Range("F5") = Date Range("C5") = strInitials ActiveWorkbook.SaveAs Filename:="G:\" & strProjectFolder & "\wp\" & strProjectFolder & " PS " & strDate & strInitials & ".xls" ActiveWorkbook.Close End Sub |
All times are GMT +1. The time now is 02:22 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com