回答編集履歴
1
1
answer
CHANGED
@@ -3,4 +3,33 @@
|
|
3
3
|
で、Excelを走査しつつ、テキスト出力でバッチファイルを作成
|
4
4
|
みたいな感じで。
|
5
5
|
ちなみに、Wshスクリプトの拡張子は .vbs になります。
|
6
|
-
適当なテキストエディタで書けばok
|
6
|
+
適当なテキストエディタで書けばok
|
7
|
+
--- 追記 ---
|
8
|
+
エラーチェックもないし、動作確認もしてませんが
|
9
|
+
参考になりますでしょうか。
|
10
|
+
```Wsh
|
11
|
+
Option Explicit
|
12
|
+
Dim args, fname, fs, xls, book, sheet, txt, i, buf
|
13
|
+
Set args = WScript.Arguments
|
14
|
+
fname = args.item(0)
|
15
|
+
Set xls = CreateObject("Excel.Application")
|
16
|
+
xls.DisplayAlerts = FALSE
|
17
|
+
Set book = xls.WorkBooks.Open(fname)
|
18
|
+
Set sheet = book.ActiveSheet
|
19
|
+
Set fs = CreateObject("Scripting.FileSystemObject")
|
20
|
+
Set txt = fs.CreateTextFile("C:\add_user.cmd", True)
|
21
|
+
i = 2
|
22
|
+
Do While sheet.Cells(i,1) <> ""
|
23
|
+
buf = "dsadd " + sheet.Cells(i,2)
|
24
|
+
txt.WriteLine buf
|
25
|
+
i = i + 1
|
26
|
+
Loop
|
27
|
+
txt.Close
|
28
|
+
Set txt = Nothing
|
29
|
+
Set fs = Nothing
|
30
|
+
xls.Quit
|
31
|
+
Set sheet = Nothing
|
32
|
+
Set book = Nothing
|
33
|
+
Set xls = Nothing
|
34
|
+
|
35
|
+
```
|