回答編集履歴
4
this_sheet\.Activateを追加(マトリクス順次入力シート以外がアクティブな場合にエラーとなるため)
test
CHANGED
@@ -102,6 +102,8 @@
|
|
102
102
|
|
103
103
|
'入力領域を範囲選択
|
104
104
|
|
105
|
+
this_sheet.Activate
|
106
|
+
|
105
107
|
this_sheet.Range(Cells(2 + 1, 6 + 1), Cells(2 + UBound(Files_1), 6 + UBound(Files_2))).Select
|
106
108
|
|
107
109
|
|
3
表現を一部修正
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
**追記:**
|
10
10
|
|
11
|
-
**アクティベートを自動で行う処理を追加しました。**
|
11
|
+
**不要とは思いましたが、念のためアクティベートを自動で行う処理を追加しました。**
|
12
12
|
|
13
13
|
**仕組みとしては、マクロの最後で10秒に1回TABキーを押下するPowerShellコマンドを実行しています。**
|
14
14
|
|
2
アクティベートを自動で行う処理を追加しました。
test
CHANGED
@@ -6,7 +6,17 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
+
**追記:**
|
10
|
+
|
11
|
+
**アクティベートを自動で行う処理を追加しました。**
|
12
|
+
|
13
|
+
**仕組みとしては、マクロの最後で10秒に1回TABキーを押下するPowerShellコマンドを実行しています。**
|
14
|
+
|
15
|
+
**入力領域が範囲選択されていることが前提となりますので、方向キーなどで範囲選択を解除しないようにご注意下さい。**
|
16
|
+
|
17
|
+
|
18
|
+
|
9
|
-
|
19
|
+
質問者様のVBAコードを一部修正したものも載せておきます。
|
10
20
|
|
11
21
|
(修正したのは最後の処理のみで、あとはインデントを付けただけです)
|
12
22
|
|
@@ -94,6 +104,60 @@
|
|
94
104
|
|
95
105
|
this_sheet.Range(Cells(2 + 1, 6 + 1), Cells(2 + UBound(Files_1), 6 + UBound(Files_2))).Select
|
96
106
|
|
107
|
+
|
108
|
+
|
109
|
+
'自動アクティベート
|
110
|
+
|
111
|
+
Call 連続キー押下("{TAB}", UBound(Files_1) * UBound(Files_2))
|
112
|
+
|
113
|
+
End Sub
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
Sub 連続キー押下(ByVal keyString As String, ByVal cnt As Long, Optional ByVal interval As Integer = 10)
|
118
|
+
|
119
|
+
Dim command As String
|
120
|
+
|
121
|
+
command = ""
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
'PowerShellコマンド生成
|
126
|
+
|
127
|
+
' 初期処理
|
128
|
+
|
129
|
+
command = command & "[void][Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms');"
|
130
|
+
|
131
|
+
command = command & "$keyString='" & keyString & "';"
|
132
|
+
|
133
|
+
command = command & "$cnt=" & cnt & ";"
|
134
|
+
|
135
|
+
command = command & "$interval=" & interval & ";"
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
' PowerShellウィンドウが表示されフォーカスが移るため、Alt+Tab押下でExcelにフォーカスを戻す
|
140
|
+
|
141
|
+
command = command & "[System.Windows.Forms.SendKeys]::SendWait('%{TAB}');"
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
' 連続キー押下
|
146
|
+
|
147
|
+
command = command & "for($i=0;$i -lt $cnt;$i++){"
|
148
|
+
|
149
|
+
command = command & " sleep -s $interval;"
|
150
|
+
|
151
|
+
command = command & " [System.Windows.Forms.SendKeys]::SendWait($keyString);"
|
152
|
+
|
153
|
+
command = command & "}"
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
'PowerShellコマンド実行
|
158
|
+
|
159
|
+
Call CreateObject("Wscript.Shell").Exec("powershell -command """ & command & """")
|
160
|
+
|
97
161
|
End Sub
|
98
162
|
|
99
163
|
```
|
1
修正箇所を明記
test
CHANGED
@@ -6,7 +6,9 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
念のため
|
9
|
+
念のため、質問者様のVBAコードを一部修正したものも載せておきます。
|
10
|
+
|
11
|
+
(修正したのは最後の処理のみで、あとはインデントを付けただけです)
|
10
12
|
|
11
13
|
|
12
14
|
|