I am not exactly sure if this is the correct area to post this question. A bit of the backstory is I am attempting to code in VBA a small macro/program that does three things. Two of these I have got working correctly. The third one is proving to be a bit harder to get going as I have not been able to find any useful information about what I am trying to do. What the macro/program does is take the serial number scanned or keyed in, rename it the correct format for imaging and deployment based on machine type. What I having issues with is getting it verified on the domain server without manually checking. It becomes a problem when I have 6000+ units to verify. I am looking for a way to add to my code a few lines to allow excel to check and see if the computer is listed on the domain. I have copied and pasted some of my code to help.
Private Sub cmdRecord_Click()
' Defines Varibles to be used
Dim iRow As Long
Dim LValue As String
Dim ws As Worksheet
Dim NameCheck As String
Set ws = Worksheets("Renamed Units")
' Searches for the next blank row for data entry
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
' Checks for a blank textbox and request data to be enter. Sets focus back on the textbox.
If Trim(Me.txtAsset.Value) = "" Then
Me.txtAsset.SetFocus
MsgBox "Pease enter an asset number."
End If
' Rename the asset number to desired name based upon checkbox value.
' Modified to reflect change in naming convention. (2019)
With ws
If chkbxOutdoor.Value = False Then
Me.txtAsset.Value = WorksheetFunction.Substitute(txtAsset.Value, "PU3W", "DSK-AP")
.Cells(iRow, 1).Value = Me.txtAsset.Text
NameCheck = Me.txtAsset.Text
Me.txtAsset.Value = ""
Me.txtAsset.SetFocus
Else
lastfive = Right(Me.txtAsset.Value, 5)
LValue = "LAP-TOP" & lastfive
.Cells(iRow, 1).Value = LValue
chkbxOutdoor.Value = False
NameCheck = LValue
Me.txtAsset.Value = ""
Me.txtAsset.SetFocus
End If
' Check the Active Directory Server for the remote computer name
Here I need code that will allow the variable NameCheck be used to is if the computer name is on the domain.
End With
Private Sub cmdRecord_Click()
' Defines Varibles to be used
Dim iRow As Long
Dim LValue As String
Dim ws As Worksheet
Dim NameCheck As String
Set ws = Worksheets("Renamed Units")
' Searches for the next blank row for data entry
iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
' Checks for a blank textbox and request data to be enter. Sets focus back on the textbox.
If Trim(Me.txtAsset.Value) = "" Then
Me.txtAsset.SetFocus
MsgBox "Pease enter an asset number."
End If
' Rename the asset number to desired name based upon checkbox value.
' Modified to reflect change in naming convention. (2019)
With ws
If chkbxOutdoor.Value = False Then
Me.txtAsset.Value = WorksheetFunction.Substitute(txtAsset.Value, "PU3W", "DSK-AP")
.Cells(iRow, 1).Value = Me.txtAsset.Text
NameCheck = Me.txtAsset.Text
Me.txtAsset.Value = ""
Me.txtAsset.SetFocus
Else
lastfive = Right(Me.txtAsset.Value, 5)
LValue = "LAP-TOP" & lastfive
.Cells(iRow, 1).Value = LValue
chkbxOutdoor.Value = False
NameCheck = LValue
Me.txtAsset.Value = ""
Me.txtAsset.SetFocus
End If
' Check the Active Directory Server for the remote computer name
Here I need code that will allow the variable NameCheck be used to is if the computer name is on the domain.
End With