Page 1 of 1

VBA code determine if user logged in

Posted: Thu Sep 03, 2009 6:34 am
by mitch23
Is there a way to determine through VBA whether a user is logged in to TM1? I have a reporting spreadsheet with a lot of VBA code, some of which I only want to execute if the user is logged in.

Re: VBA code determine if user logged in

Posted: Thu Sep 03, 2009 6:39 am
by Alan Kirk
mitch23 wrote:Is there a way to determine through VBA whether a user is logged in to TM1? I have a reporting spreadsheet with a lot of VBA code, some of which I only want to execute if the user is logged in.
There was a TM1User worksheet function introduced with 9.1 SP2. From your profile, it should be available for you:
The TM1User worksheet function returns the user name of the current TM1 user.

If the current TM1 user is not connected to a server, or if the specified server is not running, TM1User returns an empty string.
You can use the Application.Run method to access the worksheet function via VBA.

Re: VBA code determine if user logged in

Posted: Thu Sep 03, 2009 8:14 am
by lotsaram
Its not really clear what exactly you mean or from whose perspective you are meaning but in either case I think no vba is necessary.

If you mean that YOU as an administrator only want to do certain processes if a user is logged in you can do this just by reading the ClientProperties cube with a DBR.

If you mean certain vba should only be run by THE USER if they are logged in you could just put in a simple check to a DBR reference, if the cell returns a KEY ERR then the user is not logged in. (or if you want you could do a test with the NCONNECT macro function).

Hope that helps.