I have a spreadsheet that contains a range of model inputs that get loaded into a SQL Server database. Part of this process involves building an audit trail of who updated what and when - I record the user and machine name as well as timestamp.
Within my VBA code, I have the following:
user = VBA.environ$("username")
This is running on a Win7 machine, with Office 2013.
When I run the code, it all works fine, but when someone in production runs it (on the same machine, but they are logged in, not me), it falls over on the line above. I have used variations of the above (user = environ("username"), user = environ$("username")) but always with the same outcome - it works for me, but not for others.
Does anyone have any thoughts on how to fix this?
Here you are:
Sub Test()
With CreateObject("WScript.Network")
Debug.Print .UserName
Debug.Print .ComputerName
Debug.Print .UserDomain
End With
End Sub
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With