Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi all, is there a way of capturing either the User name or Machine name that the workbook is being opened on?, i would like to send a workbook to some people but do not want to allow them to open the workbook on any other machine than their own so if their machine is called Office1 then they can only open it on there else close the workbook, all the network users are narrowed to being able to log on on one machine only i do not want them taking the workbook home!, single machine users outside the company i would like them to only open the workbook on the machine that recieved the e-mail with the workbook in. probably an impossible task..........but maybe just maybe one of you may have an angle on this! Regards, Simon -- Simon Lloyd ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708 View this thread: http://www.excelforum.com/showthread...hreadid=553507 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Simon,
For the computer name, see the earlier post today titled "computer_name". As for the user name, Application.UserName gives you name shown in Help About Excel.. Or for the logged in user: Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long Private Sub CommandButton1_Click() Dim strUserName As String Dim RetVal As Long 'Create a buffer strUserName = String(100, Chr$(0)) 'Get the username RetVal = GetUserName(strUserName, 100) 'strip the rest of the buffer Debug.Print Left$(strUserName, InStr(strUserName, Chr$(0)) - 1) End Sub How you decide which is valid is up to you. NickHK "Simon Lloyd" wrote in message ... Hi all, is there a way of capturing either the User name or Machine name that the workbook is being opened on?, i would like to send a workbook to some people but do not want to allow them to open the workbook on any other machine than their own so if their machine is called Office1 then they can only open it on there else close the workbook, all the network users are narrowed to being able to log on on one machine only i do not want them taking the workbook home!, single machine users outside the company i would like them to only open the workbook on the machine that recieved the e-mail with the workbook in. probably an impossible task..........but maybe just maybe one of you may have an angle on this! Regards, Simon -- Simon Lloyd ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708 View this thread: http://www.excelforum.com/showthread...hreadid=553507 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I would probably use a bit of API wizardry:
' API dec Declare Function Get_User_Name Lib "advapi32.dll" Alias _ "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long ' Function: Function GetUserName() As String Dim lpBuff As String * 25 Get_User_Name lpBuff, 25 GetUserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1) End Function ' Useage: Dim strCurrentUser as String strCurrentUser = GetUserName If strCurrentUser < "Simon Lloyd" Then MsgBox "You are not authorised to view this Workbook" Else ' open End if HTH Haresoftware |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Thanks for the replies, i have no idea what API is and i would not be at liberty to install anything on anyones machine (it would be a nightmare too!), does the get user name not pick up on the machine name?, does the user of Excel always have a user name? if so then the get user name would be fine, i would just have to send a workbook to each user to collect their user name and then code their name in, am i right in assuming that when it does Get UserName i can have that user name stored in a cell so when i get the workbook back i can copy the name out from that? regards, Simon -- Simon Lloyd ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708 View this thread: http://www.excelforum.com/showthread...hreadid=553507 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi all, Does anyone know if every time excel is opened on a machine if it has a user or machine name?, i would still like to achieve my previous post above! regards, Simon -- Simon Lloyd ------------------------------------------------------------------------ Simon Lloyd's Profile: http://www.excelforum.com/member.php...fo&userid=6708 View this thread: http://www.excelforum.com/showthread...hreadid=553507 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
SHow user form when opening workbook | Excel Discussion (Misc queries) | |||
When opening a workbook, need to ensure user opens in a certain ce | Excel Discussion (Misc queries) | |||
Reference & update destin. cells on 1st machine from source workbook on 2nd machine. | Excel Discussion (Misc queries) | |||
Opening workbook in user-defined folder | Excel Worksheet Functions | |||
Opening a user selected workbook | Excel Programming |