Solved

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

Posted on 2008-10-09
2
1,776 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 500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

756 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