![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Naming a text file from a selection in a listbox Is it possible to have a text file named per a selection from a list box. I am writing the script to list all the pcs in the offic.....created an html file to load the list box and I select the computer and have the script run giving me all the information I wanted.... in the vbs file here is what i am using to name the text file... Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.CreateTextFile("c:\Scripts\inventory.txt") But I want "inventory.txt" to be named "k42.txt" because I selected that from the list of computers..... <select size="4" name="Listbox1"> <option value="k42">k42</option> <option value="mtj27">mtj27</option> <option value="mtj26">mtj26</option> |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Naming a text file from a selection in a listbox "KBJM" <KBJM@xxxxxx> wrote in message news:22D62D71-6F54-402B-8BAD-586282287319@xxxxxx Quote: > Is it possible to have a text file named per a selection from a list box. > I > am writing the script to list all the pcs in the offic.....created an html > file to load the list box and I select the computer and have the script > run > giving me all the information I wanted.... > > in the vbs file here is what i am using to name the text file... > > Set objFSO = CreateObject("Scripting.FileSystemObject") > Set objTextFile = objFSO.CreateTextFile("c:\Scripts\inventory.txt") > > But I want "inventory.txt" to be named "k42.txt" because I selected that > from the list of computers..... > > <select size="4" name="Listbox1"> > <option value="k42">k42</option> > <option value="mtj27">mtj27</option> > <option value="mtj26">mtj26</option> '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Option Explicit Dim oIE, oWSH, i, sSelected, bIE, objFSO, objTextFile Set oIE = WScript.CreateObject("InternetExplorer.Application", "IE_") Set oWSH = CreateObject("WScript.Shell") oIE.navigate "about:blank" Do Until oIE.ReadyState = 4 WScript.Sleep 100 Loop oIE.StatusBar = False oIE.Toolbar = False oIE.document.title = "Example" oIE.visible = True For i = 1 to 10 If oWSH.AppActivate(oIE.document.title) Then Exit For WScript.Sleep 100 Next oWSH.AppActivate oIE.document.title With oIE.document.body .innerHTML = "<select size='4' name='Listbox1'>" _ & "<option value='k42'>k42</option>" _ & "<option value='mtj27'>mtj27</option>" _ & "<option value='mtj26'>mtj26</option>" _ End With oIE.document.all.Listbox1.onChange = GetRef("Selected") bIE = True Do While bIE WScript.Sleep 100 Loop Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.CreateTextFile("c:\Scripts\" & _ sSelected & ".txt") Sub Selected sSelected = oIE.document.all.Listbox1.value bIE = False oIE.Quit End Sub Sub IE_onQuit If bIE Then WScript.Quit End Sub '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Parse CSV file and display Column B in HTA ListBox | VB Script | |||
| Desktop Folder/File naming? | Vista General | |||
| RC2 - Doc bug or file naming issue? | PowerShell | |||
| Naming a file with only an extension and no name | Vista General | |||