Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
OPen and close file | Excel Programming | |||
changing current directory to that of the current open file | Excel Programming | |||
Text file open and close VBA | Excel Programming | |||
VBA - on a button event, open another closed file, post changes, close file | Excel Programming | |||
Automate open file, update links, run macro, close and save file | Excel Programming |