Jump to content

help with listing all files in a folder in to a list box using HTA and vbscript


Recommended Posts

Posted

hi all

 

I am working on making a list box in HTA making a manual list box is fine, making the list box that builds it self again fine but what I am trying to do is list all files in a folder and then use that info in the list box. this is what i have at this point

 

My HTML application

APPLICATIONNAME="My HTML application"

ID="MyHTMLapplication"

VERSION="1.0"/>

 

 

Sub Window_OnLoad

Dim FolderPath

 

'folder to be searched for files

Dim objFSO

Dim objFolder

Dim colFiles

Dim objFile

Dim objOption

FolderPath = "\\server\installscripts$"

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFolder = objFSO.GetFolder(FolderPath)

Set colFiles = objFolder.Files

 

For Each objFile in colFiles

Set objOption = objFile.Name

objOption.text = objFile.Name

objOption.Value = objFile.Name

mylistbox.Add(objOption)

Next

End Sub

 

 

 

 

 

 

 

the error i am getting is error with hta.jpg

 

thank you

Posted

Set objOption = objFile.Name

objOption.text = objFile.Name

objOption.Value = objFile.Name

 

Why?

 

If all you want is to add the name to it, you won't even need objects as such.

 

Steve

Posted

hey all

 

I have fixed it. replace the for each with the following

 

For Each objFile in colFiles

Set objOption = Document.createElement("OPTION")

objOption.Text = objFile.Name

objOption.Value = objFile.Name

mylistbox.Add(objOption)

Next

 

hope this helps some one and thank you for your reply Steve21

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • 47 When would you like EduGeek EDIT 2025 to be held?

    1. 1. Select a time period you can attend


      • I can make it in June\July
      • I can make it in August\Sept
      • Other time period. Comment below
      • Either time

×
×
  • Create New...