Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 239
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 239
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Restrict Users Restrict Users Excel Discussion (Misc queries) 1 January 12th 09 05:27 PM
how do you restrict the users from copying and pasting Raja Excel Discussion (Misc queries) 1 May 14th 08 01:24 PM
how do i restrict users from changing my formulas Help with formulas Excel Discussion (Misc queries) 2 July 27th 06 10:55 PM
restrict users Restricted user access for exel workbook Excel Worksheet Functions 0 March 15th 06 03:27 PM
Is there any way for me to allow or restrict individual users' ab. hsobah Excel Worksheet Functions 1 January 14th 05 09:26 PM


All times are GMT +1. The time now is 03:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"