Monday, February 14, 2011

How to get windows login name in VBA

While developing macros, many a times we come to a situation where we want the windows login id of the user. Use Environ function to get windows login id. Syntax is as follows...

Environ ("username") --> Returns the windows login id of the user.

Tip: I found this function very useful while uploading or updating data from excel to SQL database. Along with updating SQL records, I generally update the user id in the record itself for future reference and tracking.

No comments:

Post a Comment