-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathexcel.sb
More file actions
103 lines (74 loc) · 2.36 KB
/
excel.sb
File metadata and controls
103 lines (74 loc) · 2.36 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import COM.bas
'on error resume next
filename = "c:\\warehouse.xls"
if FileExists(filename) then
print "File already exists deleting: ", filename,"\n"
delete filename
end if
oExcelApp = com::CreateObject("Excel.Application")
if oExcelApp = 0 then
print "Failed to create Excel Object do you have it installed?"
end
end if
'vbs: Set ExcelWorkbook = ExcelApp.Workbooks.Add
oWorkBook = com::CallByName(oExcelApp, "Workbooks", vbGet)
if oWorkBook = 0 then
print "Failed to create Workbook"
end
end if
oExcelWorkbook = com::CallByName(oWorkBook, "Add")
'vbs: Set ExcelSheet = ExcelWorkbook.Worksheets(1)
oExcelSheet = com::CallByName(oExcelWorkbook, "Worksheets", vbGet, 1)
if oExcelSheet = 0 then
print "Failed to get oExcelSheet"
end
end if
print "Adding cells...\n"
oRange = com::CallByName(oExcelSheet, "Range", vbGet, "G3")
if oRange = 0 then
print "Failed to get oRange"
end
end if
com::CallByName(oRange, "Value", vbLet, "123")
com::ReleaseObject(oRange)
oRange = com::CallByName(oExcelSheet, "Range", vbGet, "B1:B5")
if oRange = 0 then
print "Failed to get oRange"
end
end if
' Place BOLD border around range
CONST XlBorderWeight_xlMedium = -4138
com::CallByName(oRange, "BorderAround", vbMethod,1,XlBorderWeight_xlMedium,3)
'if oBorder = 0 then
' print "Failed to get border"
' end
'end if
'com::CallByName(oBorder, "Weight", vbLet, XlBorderWeight_xlMedium)
'com::ReleaseObject(oBorder)
oInterior = com::CallByName(oRange, "Interior", vbGet)
if oInterior = 0 then
print "Failed to get oInterior"
end
end if
com::CallByName(oInterior, "ColorIndex", vbLet, "38")
com::CallByName(oInterior, "Pattern", vbLet, "xlSolid")
com::ReleaseObject(oRange)
com::ReleaseObject(oInterior)
for i=0 to 10
for j=0 to 10
'vbs: ExcelSheet.Cells(i, j).Value = "test-" & i & "-" & j
oCell = com::CallByName(oExcelSheet, "Cells", vbGet, i, j)
com::CallByName(oCell, "Value", vbLet, "test-" & i & "-" & j)
com::ReleaseObject(oCell)
next
next
print "Saving document as:", filename, "\n"
com::CallByName(oExcelWorkbook, "SaveAs", vbMethod, filename)
com::CallByName(oExcelWorkbook, "Close")
com::CallByName(oExcelApp, "Quit")
print "Releasing objects from memory...\n"
com::ReleaseObject(oExcelSheet)
com::ReleaseObject(oExcelWorkbook)
com::ReleaseObject(oWorkBook)
com::ReleaseObject(oExcelApp)
print "Script complete!\n"