-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathexcel.sb
More file actions
50 lines (36 loc) · 1.19 KB
/
excel.sb
File metadata and controls
50 lines (36 loc) · 1.19 KB
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
47
48
49
50
import com.inc
'on error resume next
filename = "c:\\warehouse.xls"
if FileExists(filename) then
print "File already exists deleting: ", filename,"\n"
delete filename
end if
oExcelApp = CreateObject("Excel.Application")
if oExcelApp = 0 then
print "Failed to create Excel Object do you have it installed?"
return
end if
'vbs: Set ExcelWorkbook = ExcelApp.Workbooks.Add
oWorkBook = CallByName(oExcelApp, "Workbooks", vbGet)
oExcelWorkbook = CallByName(oWorkBook, "Add")
'vbs: Set ExcelSheet = ExcelWorkbook.Worksheets(1)
oExcelSheet = CallByName(oExcelWorkbook, "Worksheets", vbGet, 1)
print "Adding cells...\n"
for i=0 to 10
for j=0 to 10
'vbs: ExcelSheet.Cells(i, j).Value = "test-" & i & "-" & j
oCell = CallByName(oExcelSheet, "Cells", vbGet, i, j)
CallByName(oCell, "Value", vbLet, "test-" & i & "-" & j)
ReleaseObject(oCell)
next
next
print "Saving document as:", filename, "\n"
CallByName(oExcelWorkbook, "SaveAs", vbMethod, filename)
CallByName(oExcelWorkbook, "Close")
CallByName(oExcelApp, "Quit")
print "Releasing objects from memory...\n"
ReleaseObject(oExcelSheet)
ReleaseObject(oExcelWorkbook)
ReleaseObject(oWorkBook)
ReleaseObject(oExcelApp)
print "Script complete!\n"