+ Reply to Thread
Results 1 to 8 of 8

"Forward locking" a workbook by limiting authorized use to a certain PC name

  1. #1
    Registered User
    Join Date
    06-20-2015
    Location
    US
    MS-Off Ver
    2013
    Posts
    11

    "Forward locking" a workbook by limiting authorized use to a certain PC name

    I've been trying to figure out a way to send a workbook to a customer but preventing them from forwarding it to others. I've investigated several options in this forum:
    1) password protection - easily hacked and customer can always email someone the password in addition to the file
    2) Restricting Permission by People via Windows Live ID - difficult to do with Office 2013 and my IT sysadmin says that this will only work internally in my company

    But here's an idea that I'd love some feedback about:

    When opening the workbook, is there any way for VBA to check the user's PC name against a list of authorized PC names embedded in the code and if the check fails then close the workbook?

    Thanks!
    Dave

  2. #2
    Registered User
    Join Date
    07-23-2015
    Location
    Poland
    MS-Off Ver
    2010/2013
    Posts
    7

    Re: "Forward locking" a workbook by limiting authorized use to a certain PC name

    Hello,

    Yes. You can check name of PC by

    Please Login or Register  to view this content.

    Ex.

    Please Login or Register  to view this content.
    Last edited by pssytek; 07-29-2015 at 09:16 AM.

  3. #3
    Forum Contributor
    Join Date
    09-05-2011
    Location
    Essex, England
    MS-Off Ver
    Excel 2003 Excel 2007
    Posts
    383

    Re: "Forward locking" a workbook by limiting authorized use to a certain PC name

    its possible however if the end user hasn't enabled macro's etc. it wouldn't be triggered in the first instance. You could set some code to "very hide" every sheet apart from a holding sheet advising the user to enable the content, when closing so that if macros are disabled that's all they see.

    however to answer your question directly; put this in a module

    Please Login or Register  to view this content.
    and put this in the workbook_open event
    call Check_Host

  4. #4
    Registered User
    Join Date
    06-20-2015
    Location
    US
    MS-Off Ver
    2013
    Posts
    11

    Re: "Forward locking" a workbook by limiting authorized use to a certain PC name

    Thanks!!

    This looks promising, but I changed EXAMPLE_COMPUTER_NAME to my computer name as I found it in Settings > PC Info in Windows 8 and it auto-closes the workbook when i open it regardless of whether i use ".Close False" or ".Close True". Were you able to get this working on your PC?

  5. #5
    Forum Contributor
    Join Date
    09-05-2011
    Location
    Essex, England
    MS-Off Ver
    Excel 2003 Excel 2007
    Posts
    383

    Re: "Forward locking" a workbook by limiting authorized use to a certain PC name

    True or False just tells excel to save the workbook (true = save false = don't save) before close.

    in a different workbook try using
    Please Login or Register  to view this content.
    this should print what excel beleives your pc name to be just copy and paste into the code above. perhaps there's a "hidden" space in thier somehwere.

  6. #6
    Registered User
    Join Date
    06-20-2015
    Location
    US
    MS-Off Ver
    2013
    Posts
    11

    Re: "Forward locking" a workbook by limiting authorized use to a certain PC name

    Thanks Kramxel.

    Sorry to be dense but I put your Sub Check_Host code into the Workbook_Open event of ThisWorkbook. But i'm confused because you said I should put it into a module but I can't select a Workbook_Open event from Module1. And I'm not sure what you mean by call Check_Host.

    Sorry, but I'm a bit of a novice just trying to do my best...

  7. #7
    Registered User
    Join Date
    06-20-2015
    Location
    US
    MS-Off Ver
    2013
    Posts
    11

    Re: "Forward locking" a workbook by limiting authorized use to a certain PC name

    Ah, I figured it out. Thanks! This is a thing of beauty.

    What about also putting in a "kill pill" expiration date by checking system date against a date in the code. if it's system date <= kill pill date then do nothing. if it's past the kill pill date then activeworkbook.close

    Any idea how I would do something like this in addition to your computername method?

  8. #8
    Forum Contributor
    Join Date
    09-05-2011
    Location
    Essex, England
    MS-Off Ver
    Excel 2003 Excel 2007
    Posts
    383

    Re: "Forward locking" a workbook by limiting authorized use to a certain PC name

    Please Login or Register  to view this content.
    I've added simple msgboxes so that you can see some of the details but by all means delete/comment these out for other code you might want to run.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. removing "Select All" and limiting filter choices in a Pivot table
    By jettabar99 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 09-25-2013, 09:07 AM
  2. Need VBA Code to "redirect" not "forward" an email
    By derrikhu in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 09-08-2013, 10:59 PM
  3. Locking a workbook as "Final" question...
    By VACaver in forum Excel General
    Replies: 3
    Last Post: 01-18-2013, 01:45 PM
  4. Replies: 0
    Last Post: 11-16-2012, 04:04 PM
  5. Limiting Large Number displays to omit "hundreds"
    By NWheatley in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-09-2012, 01:44 PM
  6. Looping backward or forward? "Step -" construct. VBA
    By Lifeseeker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2012, 11:03 AM
  7. How to display the user "locking" a workbook or an addin.
    By Stefano Gatto in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-02-2006, 04:05 AM
  8. [SOLVED] shared workbook keeps locking and &amp;quot;unsharing&amp;quot; - why?
    By Peter@TGS in forum Excel General
    Replies: 1
    Last Post: 08-19-2005, 07:05 AM

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