+ Reply to Thread
Results 1 to 2 of 2

Close Current File Then Open New file

  1. #1
    Steve Roberts
    Guest

    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. #2
    Jim Cone
    Guest

    Re: Close Current File Then Open New file

    Steve,

    Have you tried "SaveCopyAs" instead of "SaveAs" ?

    Regards,
    Jim Cone
    San Francisco, USA


    "Steve Roberts" <[email protected]> wrote in message
    news:[email protected]...
    > 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1