From: Erik Gjertsen on
I Wish to crate users with sourse from excel in Active Directory

Set objExcel = CreateObject("Excel.Application") .....................Error
Set objWorkbook = objExcel.Workbooks.Open _
("C:\Scripts\New_users.xls")
intRow = 2
Do Until objExcel.Cells(intRow,1).Value = ""
Set objOU = GetObject("ou=test, dc=gjertsen, dc=as")
Set objUser = objOU.Create _
("User", "cn=" & objExcel.Cells(intRow, 1).Value)
objUser.sAMAccountName = objExcel.Cells(intRow, 2).Value
objUser.GivenName = objExcel.Cells(intRow, 3).Value
objUser.SN = objExcel.Cells(intRow, 4).Value
objUser.AccountDisabled = FALSE
objUser.SetInfo
intRow = intRow + 1
Loop
objExcel.Quit


Thanks
Erik Gjertsen


From: Richard Mueller on
Erik Gjertsen wrote:

>I Wish to crate users with sourse from excel in Active Directory
>
> Set objExcel = CreateObject("Excel.Application")
> .....................Error
> Set objWorkbook = objExcel.Workbooks.Open _
> ("C:\Scripts\New_users.xls")
> intRow = 2
> Do Until objExcel.Cells(intRow,1).Value = ""
> Set objOU = GetObject("ou=test, dc=gjertsen, dc=as")
> Set objUser = objOU.Create _
> ("User", "cn=" & objExcel.Cells(intRow, 1).Value)
> objUser.sAMAccountName = objExcel.Cells(intRow, 2).Value
> objUser.GivenName = objExcel.Cells(intRow, 3).Value
> objUser.SN = objExcel.Cells(intRow, 4).Value
> objUser.AccountDisabled = FALSE
> objUser.SetInfo
> intRow = intRow + 1
> Loop
> objExcel.Quit

Hi,

I get that error if Excel is not installed on the computer where the script
is running. Also, don't you want to use objWorkbook.Cells in your loop
rather than objExcel.Cells? In fact, I use:
================
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open "C:\Scripts\New_users.xls")
Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

Do Until objSheet.Cells(intRow, 1).Value = ""
================
I would have to test your syntax. Finally, to be more efficient, I would
bind objOU outside the loop, so it is only bound once.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net


From: Erik Gjertsen on
Thants it helps
Erik Gjertsen

"Richard Mueller" <rlmueller-NOSPAM(a)ameritech.NOSPAM.net> skrev i melding
news:Otc1OuAMGHA.3276(a)TK2MSFTNGP09.phx.gbl...
> Erik Gjertsen wrote:
>
> >I Wish to crate users with sourse from excel in Active Directory
> >
> > Set objExcel = CreateObject("Excel.Application")
> > .....................Error
> > Set objWorkbook = objExcel.Workbooks.Open _
> > ("C:\Scripts\New_users.xls")
> > intRow = 2
> > Do Until objExcel.Cells(intRow,1).Value = ""
> > Set objOU = GetObject("ou=test, dc=gjertsen, dc=as")
> > Set objUser = objOU.Create _
> > ("User", "cn=" & objExcel.Cells(intRow, 1).Value)
> > objUser.sAMAccountName = objExcel.Cells(intRow, 2).Value
> > objUser.GivenName = objExcel.Cells(intRow, 3).Value
> > objUser.SN = objExcel.Cells(intRow, 4).Value
> > objUser.AccountDisabled = FALSE
> > objUser.SetInfo
> > intRow = intRow + 1
> > Loop
> > objExcel.Quit
>
> Hi,
>
> I get that error if Excel is not installed on the computer where the
script
> is running. Also, don't you want to use objWorkbook.Cells in your loop
> rather than objExcel.Cells? In fact, I use:
> ================
> Set objExcel = CreateObject("Excel.Application")
> objExcel.Workbooks.Open "C:\Scripts\New_users.xls")
> Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)
>
> Do Until objSheet.Cells(intRow, 1).Value = ""
> ================
> I would have to test your syntax. Finally, to be more efficient, I would
> bind objOU outside the loop, so it is only bound once.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab - http://www.rlmueller.net
>
>