Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OPen and close file Alvin Hansen[_2_] Excel Programming 5 January 25th 05 01:01 PM
changing current directory to that of the current open file unnameable Excel Programming 2 May 19th 04 11:14 AM
Text file open and close VBA Karpgam Excel Programming 3 May 17th 04 04:31 AM
VBA - on a button event, open another closed file, post changes, close file Fio Excel Programming 0 March 1st 04 01:08 PM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


All times are GMT +1. The time now is 06:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"