View Full Version : Spreadsheet in to HTA using VBscript

06-03-2009, 01:26 PM
I need a little help please.

I got this code from good old Mixcrosft (http://www.microsoft.com/technet/scriptcenter/topics/activex/spreadsheet.mspx), it shows the exmple how Embedding a Spreadsheet Within an HTA is possible.

This is what I need, how can I modify the "Sub GetProcesses" to pull the data from a csv file or a xls file or evena txt file?

<title>Spreadsheet Example</title>

<Script Language="VBScript">

Sub Window_Onload
Spreadsheet1.TitleBar.Caption = "Process Information"
End Sub

Sub GetProcesses
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * From Win32_Process")
i = 1

For Each objProcess in colProcesses
strCell = "A" & i
Spreadsheet1.Range(strCell).Cells(1) = objProcess.Name
strCell = "B" & i
Spreadsheet1.Range(strCell).Cells(1) = objProcess.WorkingSetSize
strCell = "C" & i
Spreadsheet1.Range(strCell).Cells(1) = objProcess.HandleCount
i = i + 1
End Sub


<body bgcolor="buttonface">

<object classid="clsid:0002E559-0000-0000-C000-000000000046" id="Spreadsheet1">
<param name="DisplayToolbar" value="0">
<param name="DisplayWorkbookTabs" value="0">
<param name="DisplayTitleBar" value="-1">

<p><input type="button" value="Get Process Information" onclick="GetProcesses">