Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Only opening a workbook by User Name or Machine Name???


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Only opening a workbook by User Name or Machine Name???

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Only opening a workbook by User Name or Machine Name???

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Only opening a workbook by User Name or Machine Name???


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Only opening a workbook by User Name or Machine Name???


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
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
SHow user form when opening workbook Wanna Learn Excel Discussion (Misc queries) 2 June 26th 07 06:30 PM
When opening a workbook, need to ensure user opens in a certain ce Gover Excel Discussion (Misc queries) 4 April 11th 07 03:06 PM
Reference & update destin. cells on 1st machine from source workbook on 2nd machine. [email protected] Excel Discussion (Misc queries) 6 February 28th 06 05:15 AM
Opening workbook in user-defined folder pdberger Excel Worksheet Functions 0 August 26th 05 04:09 PM
Opening a user selected workbook David Hall[_5_] Excel Programming 2 January 6th 05 07:56 PM


All times are GMT +1. The time now is 10:23 PM.

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

About Us

"It's about Microsoft Excel"