Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Naming a text file from a selection in a listbox

Reply
 
Old 10-29-2008   #1 (permalink)
KBJM


 
 

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 SpecsSystem Spec
Old 10-29-2008   #2 (permalink)
James Whitlow


 
 

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>
See if this is along the lines of what you are looking for:

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46