+ Reply to Thread
Results 1 to 12 of 12

"Licence" an excel spreadsheet

Hybrid View

  1. #1
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: "Licence" an excel spreadsheet

    A simple thing would be to close the workbook if the windows logon doesn't match, something like this
    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Dim sh As Worksheet
    Sheets("Welcome").Visible = xlSheetVisible
    For Each sh In Sheets
    sh.Visible = xlSheetVeryHidden
    Next sh
    End Sub
     
    Private Sub Workbook_Open()
    Dim sh As Worksheet
    If Environ("username") <> "Simon" Then
    Application.Quit
    Else
    For Each sh In Sheets
    sh.Visible = xlSheetVisible
    Next sh
    Sheets("Welcome").Visible = xlSheetHidden
    End If
    End Sub
    Don't forget to create a Welcome sheet, and the code goes in the ThisWorkbook module.
    Last edited by shg; 02-24-2009 at 09:49 PM. Reason: deleted spurious quote
    Not all forums are the same - seek and you shall find

  2. #2
    Registered User
    Join Date
    02-09-2006
    Posts
    8

    Re: "Licence" an excel spreadsheet

    Quote Originally Posted by Simon Lloyd View Post
    A simple thing would be to close the workbook if the windows logon doesn't match, something like this
    Don't forget to create a Welcome sheet, and the code goes in the ThisWorkbook module.

    Thanks, you guys are legends.

    That sounds doable, the only quesiton being, can I set this up so I can list users (using Or rather than =??). Otherwise I would have to change it all the time for each update and each user. If you think I can list the users, can you show me how this might look in the code that you have shown above please and thank you...

  3. #3
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161

    Re: "Licence" an excel spreadsheet

    Quote Originally Posted by Vim View Post
    Thanks, you guys are legends.

    That sounds doable, the only quesiton being, can I set this up so I can list users (using Or rather than =??). Otherwise I would have to change it all the time for each update and each user. If you think I can list the users, can you show me how this might look in the code that you have shown above please and thank you...
    Yes you can use OR but you have to understand that Excel security is NOT there to protect a product but merely to protect against inadvertent changes, any user above casual status or with a bit of determination will find a way round it. What i have given is a very simplistic version of protection, there is a lot more you can do but then you also need to understand VBA better first as you have to maintain it. The sheets are made xlSheetVeryHidden which means they can only be made visible by using vba and not from the worksheet menubar.

  4. #4
    Registered User
    Join Date
    02-09-2006
    Posts
    8

    Talking Re: "Licence" an excel spreadsheet

    Quote Originally Posted by Simon Lloyd View Post
    Yes you can use OR but you have to understand that Excel security is NOT there to protect a product but merely to protect against inadvertent changes, any user above casual status or with a bit of determination will find a way round it. What i have given is a very simplistic version of protection, there is a lot more you can do but then you also need to understand VBA better first as you have to maintain it. The sheets are made xlSheetVeryHidden which means they can only be made visible by using vba and not from the worksheet menubar.
    The option you describes will suit me, I suppose any protection can be beaten, but what you have described would be superior knowledge to what most of the likely users will have.
    I will give it a try and if i have some problems will no doubt be back to ask for more advice.

    Thanks guys, really helpful!

  5. #5
    Registered User
    Join Date
    06-09-2015
    Location
    nepal
    MS-Off Ver
    2007
    Posts
    1

    Re: "Licence" an excel spreadsheet

    hello can you teach me the process to insert this code to excel im new in this.

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Dim sh As Worksheet
    Sheets("Welcome").Visible = xlSheetVisible
    For Each sh In Sheets
    sh.Visible = xlSheetVeryHidden
    Next sh
    End Sub

    Private Sub Workbook_Open()
    Dim sh As Worksheet
    If Environ("username") <> "Simon" Then
    Application.Quit
    Else
    For Each sh In Sheets
    sh.Visible = xlSheetVisible
    Next sh
    Sheets("Welcome").Visible = xlSheetHidden
    End If
    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