Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Restrict AddIn to limited users
I have developed a addin for our internal usage.
I need to restrict the usage of this addin to only limited users. This is to be in such a way that even if someone copies and installs the addin file on other PC, he want be able to use it unless we authorise the same. Can I have some pointers or sample code to start with? I dont mind lanthy process if it works. Regards, Madiya |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Restrict AddIn to limited users
You could hardcode the usernames in your application, then check
Application.Username against that list. --JP On Oct 21, 5:37*am, Madiya wrote: I have developed a addin for our internal usage. I need to restrict the usage of this addin to only limited users. This is to be in such a way that even if someone copies and installs the addin file on other PC, he want be able to use it unless we authorise the same. Can I have some pointers or sample code to start with? I dont mind lanthy process if it works. Regards, Madiya |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Restrict AddIn to limited users
Application.Username against that list. This isn't a good approach because the user can change the UserName property in the Options dialog. If you are going to go down the username road, you would be better using the Windows user name. You can read this from an environment variable with: Dim CurrentUser As String CurrentUser = Environ("UserName") I have, however, on rare occasion found circumstances in which the user name isn't available as an environment variable. To be extra safe, use the GetUserName Windows API function: Public Declare Function GetUserName Lib "advapi32.dll" _ Alias "GetUserNameA" ( _ ByVal lpBuffer As String, _ nSize As Long) As Long Sub Test() Dim L As Long Dim S As String L = 255 S = Space$(L) L = GetUserName(S, L) L = InStr(1, S, vbNullChar) S = Left(S, L - 1) Debug.Print S End Sub Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group, 1998 - 2010 Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Wed, 21 Oct 2009 06:30:52 -0700 (PDT), JP wrote: You could hardcode the usernames in your application, then check Application.Username against that list. --JP On Oct 21, 5:37*am, Madiya wrote: I have developed a addin for our internal usage. I need to restrict the usage of this addin to only limited users. This is to be in such a way that even if someone copies and installs the addin file on other PC, he want be able to use it unless we authorise the same. Can I have some pointers or sample code to start with? I dont mind lanthy process if it works. Regards, Madiya |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Restrict AddIn to limited users
On Oct 22, 1:14*am, Chip Pearson wrote:
Application.Username against that list. This isn't a good approach because the user can change the UserName property in the Options dialog. If you are going to go down the username road, you would be better using the Windows user name. You can read this from an environment variable with: Dim CurrentUser As String CurrentUser = Environ("UserName") I have, however, on rare occasion found circumstances in which the user name isn't available as an environment variable. To be extra safe, use the GetUserName Windows API function: Public Declare Function GetUserName Lib "advapi32.dll" _ * * Alias "GetUserNameA" ( _ * * ByVal lpBuffer As String, _ * * nSize As Long) As Long Sub Test() * * Dim L As Long * * Dim S As String * * L = 255 * * S = Space$(L) * * L = GetUserName(S, L) * * L = InStr(1, S, vbNullChar) * * S = Left(S, L - 1) * * Debug.Print S End Sub Cordially, Chip Pearson Microsoft Most Valuable Professional * * Excel Product Group, 1998 - 2010 Pearson Software Consulting, LLCwww.cpearson.com (email on web site) On Wed, 21 Oct 2009 06:30:52 -0700 (PDT), JP wrote: You could hardcode the usernames in your application, then check Application.Username against that list. --JP On Oct 21, 5:37*am, Madiya wrote: I have developed a addin for our internal usage. I need to restrict the usage of this addin to only limited users. This is to be in such a way that even if someone copies and installs the addin file on other PC, he want be able to use it unless we authorise the same. Can I have some pointers or sample code to start with? I dont mind lanthy process if it works. Regards, Madiya- Hide quoted text - - Show quoted text - Thanks to both. Chip : Your code is exactly what I was looking for. However, line S = Space$(L) is having "$" after space. Can you pl explain this. I have tried without $ which also works all the same. Regards, Madiya |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Restrict Users | Excel Discussion (Misc queries) | |||
how do you restrict the users from copying and pasting | Excel Discussion (Misc queries) | |||
how do i restrict users from changing my formulas | Excel Discussion (Misc queries) | |||
restrict users | Excel Worksheet Functions | |||
Is there any way for me to allow or restrict individual users' ab. | Excel Worksheet Functions |