pscrawford
New Member
- Joined
- May 6, 2011
- Messages
- 1
Hello, I am attempting to get user names each time an individual utilizes a model that we built. I am testing the following code in VB
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function UserNameWindows() As String
Dim lngLen As Long
Dim strBuffer As String
Const dhcMaxUserName = 255
strBuffer = Space(dhcMaxUserName)
lngLen = dhcMaxUserName
If CBool(GetUserName(strBuffer, lngLen)) Then
UserNameWindows = Left$(strBuffer, lngLen - 1)
Else
UserNameWindows = ""
End If
End Function
to pull back user name
Function ComputerName() As String
ComputerName = Environ("COMPUTERNAME")
End Function
to pull back computer name
Function UserNameOffice() As String
UserNameOffice = Application.UserName
End Function
to pull back User Id
Issue that I am having is that when others open the model they continue to see my credentials. I had the individuals modify the "Enable ALL macros" within the Trust Center however this does not seem to fix the issue. When I have them change back to "Disable Macros with notification" which they are then prompted to enable Macros there information then populates.
Is there something that I am not including within the VB language? Stumped!!
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Function UserNameWindows() As String
Dim lngLen As Long
Dim strBuffer As String
Const dhcMaxUserName = 255
strBuffer = Space(dhcMaxUserName)
lngLen = dhcMaxUserName
If CBool(GetUserName(strBuffer, lngLen)) Then
UserNameWindows = Left$(strBuffer, lngLen - 1)
Else
UserNameWindows = ""
End If
End Function
to pull back user name
Function ComputerName() As String
ComputerName = Environ("COMPUTERNAME")
End Function
to pull back computer name
Function UserNameOffice() As String
UserNameOffice = Application.UserName
End Function
to pull back User Id
Issue that I am having is that when others open the model they continue to see my credentials. I had the individuals modify the "Enable ALL macros" within the Trust Center however this does not seem to fix the issue. When I have them change back to "Disable Macros with notification" which they are then prompted to enable Macros there information then populates.
Is there something that I am not including within the VB language? Stumped!!