Results 1 to 3 of 3

Need help resolving worksheet naming problem

Threaded View

  1. #1
    Registered User
    Join Date
    10-20-2012
    Location
    salinas, ca
    MS-Off Ver
    Excel 2010
    Posts
    25

    Unhappy Need help resolving worksheet naming problem

    Hello forum members,

    I need your help finding a solution to the following problem:

    I have an excel 2010 spreadsheet that creates a new sheet when it opens by saving itself with a different name... in other words, the original file is tx master.xlsm and after it's double-clicked the file saves as tx and that day's date (example: tx 01-07-2013.xlsm). I used the following to accomplish the task:
    myFolder = "C:\users\pete\desktop\"
    myFile = myFolder & "tx" & " " & Format(Date, "mm-dd-yyyy") & ".xlsm"
    If Not IsFileExists(myFile) Then
        ActiveWorkbook.SaveAs "C:\users\pete\desktop\" & "tx" & " " & Format(Date, "mm-dd-yyyy") & ".xlsm", FileFormat:=52
    End If
    The first problem came when the user had the second sheet opened and tried to double-click the original sheet; the user ended up writing data to the original sheet instead of the second one. I tried solving this issue by implementing a security check to see if the second file existed, and if so, to let the user know that he needed to use the correct file; after the user clicked "Ok" the original file closed and that was that.
    If IsFileExists(myFile) Then
        MsgBox "Today's file has been created already." & vbNewLine & "Please use that file instead of this one.", vbExclamation + vbOKOnly, "File in Use"
        ActiveWorkBook.Close SaveChanges:=False  
    End If
    But then, another problem arose: if the user closed and then tried to reopen the second file he got the same message intended for the original file; so the user got stuck in a loop in which the file doesn't open. How can this problem be avoided? I need the original file to create the second file; while keeping the user from trying to open the original file if the second file has been created; and letting the user close the second file and open it without having to deal with the messages meant to limit the use of the original file.

    Any help would be greatly appreciated!!
    Last edited by Julez80s; 01-07-2013 at 09:59 PM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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