Scripts Thread, help with listing all files in a folder in to a list box using HTA and vbscript in Coding and Web Development; hi all
I am working on making a list box in HTA making a manual list box is fine, making ...
-
2nd September 2011, 11:45 AM #1
- Rep Power
- 0
help with listing all files in a folder in to a list box using HTA and vbscript
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
<html>
<head>
<title>My HTML application</title>
<HTA:APPLICATION
APPLICATIONNAME="My HTML application"
ID="MyHTMLapplication"
VERSION="1.0"/>
</head>
<script language="VBScript">
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
</script>
<body bgcolor="white">
<!--Add your controls here-->
<select name="mylistbox" size=10>
</select>
<!--{{InsertControlsHere}}-Do not remove this line-->
</body>
</html>
the error i am getting is error with hta.jpg
thank you
-
-
IDG Tech News
-
2nd September 2011, 11:49 AM #2 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
-
-
2nd September 2011, 12:10 PM #3
- Rep Power
- 0
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
-
SHARE: 
Similar Threads
-
By meadowgirl in forum General Chat
Replies: 6
Last Post: 30th September 2010, 03:17 PM
-
By My220x in forum Coding
Replies: 2
Last Post: 10th October 2009, 11:12 PM
-
By albertwt in forum Thin Client and Virtual Machines
Replies: 0
Last Post: 3rd June 2009, 10:13 AM
-
Replies: 3
Last Post: 18th January 2008, 01:46 PM
-
By OutToLunch in forum Scripts
Replies: 3
Last Post: 25th September 2006, 12:27 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules