2009年12月5日土曜日

ruby-excel0_02.xls macro

ruby-excel0_02.xls

Sub SampleRuby01() 'OK
Dim WSH, wExec, sCmd As String, Result As String
Set WSH = CreateObject("WScript.Shell") ''(1)
' sCmd = "ruby d:\nn\!save_NN2\ruby-excel\nn01.rb" ''(2)
sCmd = "ruby d:\\nn\\!save_NN2\\ruby-excel\\nn01.rb" ''(2) ★ディレクトリ区切りは\\
Set wExec = WSH.Exec("%ComSpec% /c " & sCmd) ''(3)
Do While wExec.Status = 0 ''(4)
DoEvents
Loop
Result = wExec.StdOut.ReadAll ''(5)
MsgBox Result
Set wExec = Nothing
Set WSH = Nothing
End Sub

Sub SampleRuby02() 'OK
Dim WSH, wExec, sCmd As String, Result As String
Set WSH = CreateObject("WScript.Shell") ''(1)
sCmd = "ruby d:\\nn\\!save_NN2\\ruby-excel\\nn02.rb" ''(2)★ディレクトリ区切りは\\
Set wExec = WSH.Exec("%ComSpec% /c " & sCmd) ''(3)
Do While wExec.Status = 0 ''(4)
DoEvents
Loop
Result = wExec.StdOut.ReadAll ''(5)
' MsgBox Result '★不要
Set wExec = Nothing
Set WSH = Nothing
End Sub
---------------------------------------------------------------------------
#nn01.rb
#foo = File.open("C:\\nn\\ruby-excel\\foo.txt",'w')
#foo = File.open("D:\\nn\\ruby-excel\\foo.txt",'w')
#D:\nn\!save_NN2\ruby-excel
foo = File.open("D:\\nn\\!save_NN2\\ruby-excel\\漢字ファイル1.txt",'w')
#D:\nn\ruby-excel
foo.puts 'bar'
foo.puts '漢字'
foo.puts '漢字2'
foo.close

#nn02.rb
#foo = File.open("C:\\nn\\ruby-excel\\foo.txt",'w')
#foo = File.open("D:\\nn\\ruby-excel\\foo.txt",'w')
#D:\nn\!save_NN2\ruby-excel
foo = File.open("D:\\nn\\!save_NN2\\ruby-excel\\漢字ファイルfoo-2.txt",'w')
#D:\nn\ruby-excel
foo.puts '漢字1'
foo.puts '漢字2'
foo.puts '漢字3'
foo.close

0 件のコメント:

コメントを投稿