次のコードセットに変数を渡そうとしています:
で書かれたコンソール アプリケーションからC#
:
static void Main(string[] args) {
string myPath = @"R:\xxx\xxx\xxx\test.vbs";
Process p = new Process();
ProcessStartInfo ps = new ProcessStartInfo(myPath,"hello");
p.StartInfo = ps;
p.Start();
Console.WriteLine("press [enter] to exit");
Console.ReadLine();
}
次のtest.vbs
ファイルに:
strFolder = Wscript.Arguments.Item(0)
Set XL=CreateObject("Excel.Application")
XL.Visible=True
XL.Workbooks.Open "\\xxx\xxx\xxx\PassInVariable.xlsm",,True
XL.Run "'PassInVariable.xlsm'!xxx", strFolder '<<<<<<<<<<<<<<PROBLEM SEEMS TO BE HERE
XL.Workbooks("PassInVariable.xlsm").close false
XL.quit
Set XL=nothing
次に、PassInVariable.xlsm
ファイルには次のものがあります。
Option Explicit
Sub xxx(x As String)
MsgBox x
End Sub
strFolder
これを「hello」などのリテラルに置き換えると、変数がExcel VBAに移動するため、VBScript
ファイル 内の変数に問題があるようです。
変数が行に渡されるように vbs ファイルを修正するにはどうすればよいですか?