+ Reply to Thread
Results 1 to 4 of 4

Open unopened file

  1. #1
    Registered User
    Join Date
    05-01-2008
    Posts
    17

    Open unopened file

    At a certain stage, my program prompts user to open file "FileToOpen" where "FileToOpen" is a string variable assigned to the name of a certain file. In order to get to this point, I use the command: FileToOpen = Application.GetOpenFilename(<various filters>)

    If FileToOpen is already open, I get a system alert asking user whether thy want to overwrite FileToOpen. Rather than suppress the alert, I want my program to do something like this: (

    (Sorta using English here instead of VBA so please disregard the lack of formality):

    'IF FileToOpen is not open then open FileToOpen; Else don't open anything.'

    I suspect I am asking the impossible, but any ideas would be appreciated

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: Open unopened file

    Fairly simplistic approach but ...

    Please Login or Register  to view this content.


    So, try to assign the workbook to be opened to a variable. If it fails, it's not open. In this example, I've cleared the error, displayed a message and exited the subroutine.


    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    05-01-2008
    Posts
    17

    Re: Open unopened file

    Thank you TMShucks. Your post was helpful, but I'm keeping the thread open as I'm still hoping against hope to get exactly what I want.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,464

    Re: Open unopened file

    Can't you get exactly what you want from what I've given you?

    If not, try uploading a sample workbook with the code you have.

    Regards

+ 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