Q:

VBS output in column format

I am trying to have my .vbs output be put into columns. However, when I try write the code to organize the output into columns I continue to get an error - Invalid Procedure call or argument: 'Space'
I'm looking for some help on this, thanks!!
Call FindPCsThatUserLoggedInto

Sub FindPCsThatUserLoggedInto()

strUser = InputBox("Enter First Name")
strLast = InputBox("Enter Last Name")

Const ADS_SCOPE_SUBTREE = 2

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")

objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"

Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

's = "Name" & Chr(9) & "Account Name"  & Chr(9) &  "Location" & Chr(10) & Chr(13)
's = s & "----" & Chr(9) & "------------"  & Chr(9) &  "--------" & Chr(10) & Chr(13)
s = RightJustified("Name", 10) & _
  RightJustified("Account Name", 15) & _
  RightJustified("Location", 15) & _
  vbCrLf

objCommand.CommandText = "SELECT ADSPath FROM 'LDAP://dc=hc,dc=company,dc=com' WHERE givenName = '" & strUser & "*' AND sn = '" & strLast & "*'"

Set objRecordSet = objCommand.Execute

If objRecordSet.Recordcount > 0 Then

    objRecordSet.MoveFirst

    Do Until objRecordSet.EOF

        Set objUser = GetObject(objRecordSet.Fields("ADSPath").Value)

        's = s & objUser.DisplayName & Chr(9) & objUser.samaccountname  & Chr(9) &  objUser.PhysicalDeliveryOfficeName & Chr(10) & Chr(13)

       ' objRecordSet.MoveNext
       s = s & _
  RightJustified(objUser.DisplayName, 10) & _
  RightJustified(objUser.samaccountname, 15) & _
  RightJustified(objUser.PhysicalDeliveryOfficeName, 15) & _
  vbCrLf

    Loop

    MsgBox s

Else

    MsgBox "No users matching that criteria exist in the HC domain in AD."

End If

End Sub

Function RightJustified(ColumnValue, ColumnWidth)
RightJustified = Space(ColumnWidth - Len(ColumnValue)) & ColumnValue
End Function

This is the code that I added to organize the outputs into columns:
s = RightJustified("Name", 10) & _
  RightJustified("Account Name", 15) & _
  RightJustified("Location", 15) & _
  vbCrLf

And
       s = s & _
  RightJustified(objUser.DisplayName, 10) & _
  RightJustified(objUser.samaccountname, 15) & _
  RightJustified(objUser.PhysicalDeliveryOfficeName, 15) & _
  vbCrLf

Here is my output:

A:

My guess would be that this is a runtime error due to your data exceeding the specified size?
RightJustified(objUser.DisplayName, 10) & _
RightJustified(objUser.samaccountname, 15) & _
RightJustified(objUser.PhysicalDeliveryOfficeName, 15) & _
vbCrLf

Perhaps this change would be needed:
Function RightJustified(ColumnValue, ColumnWidth)
  If Len(ColumnValue) > ColumnWidth Then
     ColumnValue = Left(ColumnValue,ColumnWidth)
  End If
  RightJustified = Space(ColumnWidth - Len(ColumnValue)) & ColumnValue
End Function

