+ Reply to Thread
Results 1 to 5 of 5

Stop an excel workbook or worksheet from opening if workbook isn't in a certain folder

  1. #1
    Registered User
    Join Date
    09-19-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    13

    Stop an excel workbook or worksheet from opening if workbook isn't in a certain folder

    Hello All,

    Is there anyway to write some VBA code to prevent a workbook from being opened if has been moved or saved to a different folder location. The reason is to prevent people from saving the certain document to a different location, so there can only be one copy available.

    I have added in macros to prevent saving and there are macros included to save a shortcut to the users desktop so there is no need to make a copy, these work quite effectively, but the only issue is if someone doesn't allow macros to run then the document can be saved regardless of the macro preventing saving.

    So would such a macro be possible to check, if the workbook isn't located in e.g. C:/test then it will give an error message saying please use original workbook.

    Any help would be much appreciated.

    Thanks very much,

    Paul
    Last edited by Raulus; 03-05-2013 at 05:31 AM.

  2. #2
    Forum Contributor
    Join Date
    12-31-2012
    Location
    Jhang, Pakistan
    MS-Off Ver
    Excel 2010
    Posts
    250

    Re: Stop an excel workbook or worksheet from opening if workbook isn't in a certain folder

    I have added in macros to prevent saving and there are macros included to save a shortcut to the users desktop so there is no need to make a copy, these work quite effectively, but the only issue is if someone doesn't allow macros to run then the document can be saved regardless of the macro preventing saving.
    The issue is again that if someone doesn't allow macros to run then the macro written for this purpose will not work at the start-up / opening of workbook.

  3. #3
    Registered User
    Join Date
    09-19-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Stop an excel workbook or worksheet from opening if workbook isn't in a certain folder

    Thanks for your reply and valid point! But I have a cover page that shows instead of the correct worksheet unless macros are turned on, if someone does save the workbook elsewhere whilst macros are turned off and then turns on macros, they can currently use the workbook properly and they have their own copy.

    My thought was, that, yes they would be able to save the workbook elsewhere but when they then turn macros on in the workbook in their new location, it would then trigger this new macro to stop the worksheet from working as it wasn't in the correct location and then give an error message along the lines of, please use the original document, in folder S:/etc, etc.

    Does that make sense?

    Thanks,

    Paul
    Last edited by Raulus; 03-05-2013 at 04:53 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Stop an excel workbook or worksheet from opening if workbook isn't in a certain folder

    Hi -

    see
    Please Login or Register  to view this content.
    event

  5. #5
    Registered User
    Join Date
    09-19-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Stop an excel workbook or worksheet from opening if workbook isn't in a certain folder

    Thanks for pointing me in right direction event21.

    I wrote this:
    Please Login or Register  to view this content.
    The user will still be able to see the cover page whilst macros are turned off, but as soon as they activate macros whilst the workbook is in the wrong location, it shows the error message and closes the workbook.

    Thanks for your help.

    Paul
    Last edited by Raulus; 03-05-2013 at 05:34 AM.

+ 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