Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default custom settings per user?

Hi, is it possible for excel to know who has loged on to the system an
then run a macro i have set up for that user?

I'm thinking of some form of IF statment macro but i have know idea o
how to get excel to know who has logged in.

We all have different logins for the computer for example pmawle o
tsmith etc..

Regards

Pet

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 535
Default custom settings per user?

Hi Pete,

but i have know idea of
how to get excel to know who has logged in.


This gets you the name of the person logged in:

Option Explicit

Private Const MAX_USERNAME As Long = 256

Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" _
(ByVal lpBuffer As String, _
nSize As Long) As Long

Function rgbGetUserName() As String

'return the name of the user
Dim tmp As String

tmp = Space$(MAX_USERNAME)

If GetUserName(tmp, Len(tmp)) Then
rgbGetUserName = TrimNull(tmp)
End If
End Function

Private Function TrimNull(item As String)
Dim pos As Integer

pos = InStr(item, Chr$(0))

If pos Then
TrimNull = Left$(item, pos - 1)
Else: TrimNull = item
End If
End Function



Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default custom settings per user?

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
(ByVal lpBuffer As String, nSize As Long) As Long

Function ActiveUser() As String
Dim str As String
str = Space(256)
If GetUserName(str, 256) Then ActiveUser = Split(str, Chr(0), 2)(0)
End Function

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Pete JM " wrote in message
...
Hi, is it possible for excel to know who has loged on to the system and
then run a macro i have set up for that user?

I'm thinking of some form of IF statment macro but i have know idea of
how to get excel to know who has logged in.

We all have different logins for the computer for example pmawle or
tsmith etc..

Regards

Pete


---
Message posted from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default custom settings per user?

Hi Mark
Put first these declaration in a standard module :

Declare Function Get_User_Name Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long

Public Function GetUserName() As String
' By Chris Rae, 14/6/99, 3/9/00.
'Option Explicit
' This is used by GetUserName() to find the current user's
' name from the API
Dim lpBuff As String * 25
Get_User_Name lpBuff, 25
GetUserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
End Function

Then, in a sub, you can test the user name

sub test

Dim strmsgUser$
user = GetUserName
if user= "username" then
end if
end sub

Regards,

Jean-Yves

"Pete JM " wrote in message
...
Hi, is it possible for excel to know who has loged on to the system and
then run a macro i have set up for that user?

I'm thinking of some form of IF statment macro but i have know idea of
how to get excel to know who has logged in.

We all have different logins for the computer for example pmawle or
tsmith etc..

Regards

Pete


---
Message posted from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default custom settings per user?

thank you all very much! This has been really helpful Thank you!

Best regards

Pet

--
Message posted from http://www.ExcelForum.com

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
Keeping Custom Chart Settings Jim at Clark Charts and Charting in Excel 1 November 30th 07 01:22 PM
are user-defined chart settings transferrable? Ed Ireland Setting up and Configuration of Excel 0 February 15th 06 07:26 PM
Saving Print Settings - Customized for each user windsong Excel Discussion (Misc queries) 1 November 10th 05 12:38 AM
Keep custom toolbar settings - Help!! Anthony Excel Discussion (Misc queries) 4 February 26th 05 12:16 AM
Keep Custom Menu settings - help !! Anthony Excel Worksheet Functions 1 February 26th 05 12:11 AM


All times are GMT +1. The time now is 10:37 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"