+ Post New Thread
Results 1 to 3 of 3
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 ...
  1. #1

    Join Date
    Feb 2011
    Posts
    37
    Thank Post
    2
    Thanked 1 Time in 1 Post
    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

  2. #2

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,694
    Thank Post
    335
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    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

  3. #3

    Join Date
    Feb 2011
    Posts
    37
    Thank Post
    2
    Thanked 1 Time in 1 Post
    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:
+ Post New Thread

Similar Threads

  1. Replies: 5
    Last Post: 1st July 2014, 08:34 AM
  2. Replies: 6
    Last Post: 30th September 2010, 03:17 PM
  3. Replies: 2
    Last Post: 10th October 2009, 11:12 PM
  4. Confused in the Manual VM creation using SSH and Fast SCP and ESXi failover concept
    By albertwt in forum Thin Client and Virtual Machines
    Replies: 0
    Last Post: 3rd June 2009, 10:13 AM
  5. 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
  •