Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Error and Need Help ASAP

Status
Not open for further replies.

arohl74

MIS
May 9, 2003
10
0
0
US
I am trying to modify users' AD information using an Excel Spreadsheet. Here is my script:

Set objExcel = CreateObject("Excel.Application")

objExcel.DisplayAlerts = False

'intRow = 2
strFile = "C:\script\test_emp_info.xls"
strDomain = "OU=PSTEST,DC=russellreynolds,DC=com"

Set objWorkbook = objExcel.Workbooks.Open(strFile)

Do Until objExcel.Cells(intRow,1).Value = ""
Set objUser = GetObject("CN=" & objExcel.Cells(intRow,3 & intRow,2).Value "," & strDomain)
objUser.physicalDeliveryOfficeName = objExcel.Cells(intRow,6).Value
objUser.title = objExcel.Cells(intRow,8).Value
objUser.SetInfo

intRow = intRow + 1
Loop

objExcel.Quit

But I get the following error:

Line: 40
Char: 77
Error: Expected ')'
Code: 800A03EE

Any help asap would be greatly appreciated.
 
I found the issue with the above script. I left out an &.

Here is the code:

Dim objExcel, objWorkbook, objUser, strDomain, intRow, strFile

Set objExcel = CreateObject("Excel.Application")

objExcel.DisplayAlerts = False

'intRow = 2
strFile = "C:\script\test_emp_info.xls"
strDomain = "OU=PSTEST,DC=russellreynolds,DC=com"

Set objWorkbook = objExcel.Workbooks.Open(strFile)

Do Until objExcel.Cells(intRow,1).Value = ""
Set objUser = GetObject("CN=" & objExcel.Cells(intRow,3 & intRow,2).Value & "," & strDomain)
objUser.physicalDeliveryOfficeName = objExcel.Cells(intRow,6).Value
objUser.title = objExcel.Cells(intRow,8).Value
objUser.SetInfo

intRow = intRow + 1
Loop

objExcel.Quit

Now when I run it, I get the following error:

Line: 13
Char: 1
Error: Unknown runtime error
Code: 800A03EC

Any help asap is greatly appreciated.
 
If, according to the first error this line is Line 40:
Code:
Set objUser = GetObject("CN=" & objExcel.Cells(intRow,3 & intRow,2).Value & "," & strDomain)

then Line 13 isn't even displayed in the code you've given.

Can you identify which line of code you are getting the error in please?

Cheers,
Dave

"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

For all your testing needs: Forum1393
 
'intRow = 2
Why is the above commented ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
>Set objUser = GetObject("CN=" & objExcel.Cells(intRow,3 & intRow,2).Value & "," & strDomain)
If you go slower, you would go farther! This line has no chance to be correct. At least this.
[tt]Set objUser = GetObject([red]"LDAP://" & [/red]"CN=" & objExcel.Cells(intRow,3 & intRow,2).Value & "," & strDomain)[/tt]
 
Furthermore, the following should chokes Excel as Cells admits only 2 parameters:
objExcel.Cells(intRow,3 & intRow,2).Value

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you all for your help. To answer your question PHV, intRow = 2 is commented because there are no column headers. I made the suggested changes. Here is the code:

Dim objExcel, objWorkbook, objUser, strDomain, intRow, strFile

Set objExcel = CreateObject("Excel.Application")

objExcel.DisplayAlerts = False

'intRow = 2
strFile = "C:\script\test_emp_info.xls"
'strDomain = "OU=PSTEST,DC=russellreynolds,DC=com"

Set objWorkbook = objExcel.Workbooks.Open(strFile)

Do Until objExcel.Cells(intRow,1).Value = ""
Set objUser = GetObject("LDAP//" & "CN=" & objExcel.Cells(intRow,3).Value & objExcel.Cells(intRow,2).Value & "," & strDomain)
objUser.physicalDeliveryOfficeName = objExcel.Cells(intRow,6).Value
objUser.title = objExcel.Cells(intRow,8).Value
objUser.SetInfo

intRow = intRow + 1
Loop

objExcel.Quit

I still get the following error:

Line: 13
Char: 1
Error: Unknown runtime error
Code: 800A03EC

 
Replace this:
'intRow = 2
with this:
intRow = 1

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yup, PHV, that did it. I tried that this morning. Now I am getting the following error:

Line:14
Char:3
Code:800401E4

This is pointing to the LDAP line.
 
What is the value of strDomain ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
the value of strDomain is the target OU and domain that I want to bind to. It is declared in the script.
 
It is declared in the script
But the value assignment is commented out ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top