码迷,mamicode.com
首页 > 编程语言 > 详细

vba统计电脑计算机名和登陆的用户名

时间:2018-12-20 16:59:17      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:net   com   inf   amp   orm   form   mba   trim   active   

Public Sub GetIPT()
    gipt = Trim(InputBox("请输入坐在组,只需输入前面的字母代码即可 A- groupA B-groupB C-groupC D-groupD E-groupD "))
    strIPT = UCase(gipt)
    If strIPT = "A" Then GetInfo ("AirBus"): End
    If strIPT = "B" Then GetInfo ("Boeing"): End
    If strIPT = "C" Then GetInfo ("Engines"): End
    If strIPT = "D" Then GetInfo ("Bombarbier"): End
    If strIPT = "E" Then GetInfo ("BJ"): End
End Sub
Function GetInfo(IPT As String)
    Dim TheName As String
  
    
    On Error GoTo line1
    computername = Environ("Computername")
    UserName = Environ("Username")
    
    
    rw = Sheet1.Range("a65536").End(xlUp).Row
    i = 0
    i = i + rw
    Sheet2.Cells(i, 1) = computername
    Sheet2.Cells(i, 2) = UserName
    Sheet2.Cells(i, 3) = IPT
    
    Sheet2.Copy
    TheName = ThisWorkbook.Path & "./" & computername & ".xls"
    
    ActiveWorkbook.SaveAs Filename:=TheName, FileFormat:=xlNormal
    Sheet2.Range("A1:C65536").ClearContents
    MsgBox "信息已采集完," & computername & ".xls 文件已生成"
    ActiveWorkbook.Close
    
line1:

End Function

  

vba统计电脑计算机名和登陆的用户名

标签:net   com   inf   amp   orm   form   mba   trim   active   

原文地址:https://www.cnblogs.com/luoye00/p/10149902.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!