2018年08月31日 16:34
'Excel VBAのコード
'A列の数値をtest.uwsに渡してUWSCを起動する
'UWSC.exeとtest.uwsはドキュメントフォルダにあるとする
Sub test1()
Dim myDocuments As String
Dim WSH As Variant
Set WSH = CreateObject("WScript.Shell")
myDocuments = WSH.SpecialFolders("MyDocuments") & "\"
Dim uwscPath As String
Dim filePath As String
Dim args As String
'UWSC.exeのパス
uwscPath = myDocuments & "UWSC.exe"
'起動させたいUWSCのファイルのパス
filePath = myDocuments & "test.uws"
Dim i As Integer
Dim lastrow As Integer
lastrow = Cells(1, 1).End(xlDown).Row
For i = 1 To lastrow
'UWSCに渡す引数
args = Cells(i, 1) & " " & i
Dim ret As Variant
'ファイル名とUWSCに渡す引数を渡してUWSCを起動する
ret = Shell(uwscPath & " " & filePath & " " & args, vbNormalFocus)
Next
MsgBox ("終了しました。")
End Sub
//test.uwsのコード
//受け取った数値に2を掛けて、ExcelのB列に値を設定(この処理自体には意味はありません。)
double = PARAM_STR[0] * 2
EXCEL= getactiveoleobj("Excel.Application")
Excel.cells(PARAM_STR[1], 2) = double
'Excel VBAのコード
'A列の数値をtest.uwsに渡してUWSCを起動する
'UWSC.exeとtest.uwsはドキュメントフォルダにあるとする
Sub test2()
Dim myDocuments As String
Dim WSH As Variant
Set WSH = CreateObject("WScript.Shell")
myDocuments = WSH.SpecialFolders("MyDocuments") & "\"
Dim uwscPath As String
Dim filePath As String
Dim args As String
'UWSC.exeのパス
uwscPath = myDocuments & "UWSC\UWSC.exe"
'起動させたいUWSCのファイルのパス
filePath = myDocuments & "UWSC\test.uws"
Dim i As Integer
Dim lastrow As Integer
lastrow = Cells(1, 1).End(xlDown).Row
For i = 1 To lastrow
'UWSCに渡す引数
args = Cells(i, 1) & " " & i
'ファイル名とUWSCに渡す引数を渡してUWSCを起動、終了まで待つ
WSH.Run uwscPath & " " & filePath & " " & args, , True
Next
MsgBox ("終了しました。")
End Sub