VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Retrieve Computer Name and User logged in. Run inside an Excel workbook.

by Rone (9 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 14th May 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Retrieve Computer Name and User logged in. Run inside an Excel workbook.

Rate Retrieve Computer Name and User logged in. Run inside an Excel workbook.




    Dim objNet As Object
    Dim CompName As String, User_Name As String
    Dim Row As Integer, Total As Integer
    
    Set objNet = CreateObject("WScript.Network")
    CompName = objNet.computername
    User_Name = objNet.UserName
    Total = 0
    
    For Row = 2 To 10000
        If Range("IU" & Row).Value = "" And Total = 0 Then
            Range("IU" & Row).Value = "User: " & User_Name & " Computer: " & CompName
            Range("IV" & Row).Value = Now()
            Range("IU" & Row).Font.ColorIndex = 2
            Range("IV" & Row).Font.ColorIndex = 2
            Range("IU" & Row).Interior.ColorIndex = xlNone
            Range("IV" & Row).Interior.ColorIndex = xlNone
            Total = Total + 1
        End If
    Next

End Sub

Download this snippet    Add to My Saved Code

Retrieve Computer Name and User logged in. Run inside an Excel workbook. Comments

No comments have been posted about Retrieve Computer Name and User logged in. Run inside an Excel workbook.. Why not be the first to post a comment about Retrieve Computer Name and User logged in. Run inside an Excel workbook..

Post your comment

Subject:
Message:
0/1000 characters