See this answer:
To get this code to work in SolidWorks 2013 and later, you might need to use the steps I explain here:
I was able to use:
Dim UserName As String
UserName = Environ("USERNAME")
Cool. If that link helped you, please mark my answer as correct so others know the issue is resolved.