回答編集履歴

1

1

2017/02/20 12:56

投稿

takasima20
takasima20

スコア7458

test CHANGED
@@ -9,3 +9,61 @@
9
9
  ちなみに、Wshスクリプトの拡張子は .vbs になります。
10
10
 
11
11
  適当なテキストエディタで書けばok
12
+
13
+ --- 追記 ---
14
+
15
+ エラーチェックもないし、動作確認もしてませんが
16
+
17
+ 参考になりますでしょうか。
18
+
19
+ ```Wsh
20
+
21
+ Option Explicit
22
+
23
+ Dim args, fname, fs, xls, book, sheet, txt, i, buf
24
+
25
+ Set args = WScript.Arguments
26
+
27
+ fname = args.item(0)
28
+
29
+ Set xls = CreateObject("Excel.Application")
30
+
31
+ xls.DisplayAlerts = FALSE
32
+
33
+ Set book = xls.WorkBooks.Open(fname)
34
+
35
+ Set sheet = book.ActiveSheet
36
+
37
+ Set fs = CreateObject("Scripting.FileSystemObject")
38
+
39
+ Set txt = fs.CreateTextFile("C:\add_user.cmd", True)
40
+
41
+ i = 2
42
+
43
+ Do While sheet.Cells(i,1) <> ""
44
+
45
+ buf = "dsadd " + sheet.Cells(i,2)
46
+
47
+ txt.WriteLine buf
48
+
49
+ i = i + 1
50
+
51
+ Loop
52
+
53
+ txt.Close
54
+
55
+ Set txt = Nothing
56
+
57
+ Set fs = Nothing
58
+
59
+ xls.Quit
60
+
61
+ Set sheet = Nothing
62
+
63
+ Set book = Nothing
64
+
65
+ Set xls = Nothing
66
+
67
+
68
+
69
+ ```