Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using vbscript to read from an excel file and populate a drop down list

Posted on 2008-10-09
2
Medium Priority
?
1,876 Views
Last Modified: 2008-10-12
I have an excel file that contains a list of names in one row and the distinguished name in another.


I need to read the file and output the names into the drop down box while having the distinguished name be the value for the selection.

The following was my attempt, but was unsuccessful.

strXLpath = "c:\managers.xls"
      
            Set objXL = CreateObject("Excel.Application")
            objXL.visible = False
            Set objWb = objXL.WorkBooks.Open(strXLpath)
            

            objWb.MoveFirst
            Do Until objWb.EOF
                  Set objOption = Document.createElement("OPTION")
                        objOption.Text = objXL.Rows(1).Value
                        objOption.Value = objXL.Rows(2).Value
                        mgrName.Add(objOption)
                        objWB.MoveNext
            Loop


0
Comment
Question by:dhalliday
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 22682399
Hi, assuming you've got Manager name in column A and their distriguished name in Column B, try this....

Regards,

Rob.
strXLpath = "c:\managers.xls"
 
Set objXL = CreateObject("Excel.Application")
Const xlUp = -4162
objXL.visible = False
Set objWb = objXL.WorkBooks.Open(strXLpath)
Set objSheet = objWb.Sheets(1)
 
For intRow = 2 To objSheet.Cells(65536, "A").End(xlUp).Row
	Set objOption = Document.createElement("OPTION")
	objOption.Text = objSheet.Cells(intRow, "A").Value
	objOption.Value = objSheet.Cells(intRow, "B").Value
	mgrName.Add(objOption)
Next

Open in new window

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22699075
Thanks for the grade.

Regards,

Rob.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question