win32ole打开word问题
ruby吧
全部回复
仅看楼主
level 2
zhurongwell 楼主
win32ole,打开word时 ,第一次运行的时候是可以的,为什么第二次调用的时候就报错:failed to create WIN32OLE object from `Word.Application'HRESULT error code:0x800401f0
CoInitialize has not been called,可以帮我分析下嘛,ruby1.9 ,rails3.2,谢谢
2013年08月12日 09点08分 1
level 6
大概开了没关。
2013年08月12日 16点08分 2
level 9
嗯,估计是开了没关。
2013年08月13日 03点08分 3
怎么关
2013年08月13日 08点08分
level 9
xl = WIN32OLE.new('Excel.Application')wb = xl.Workbooks.Add
ws = wb.Worksheets(1)
range = ws.Range("A2:K100")
...
wb.Close
xl.Quit
range = nil
ws = nil
wb = nil
xl = nil
GC.start
https://www.ruby-forum.com/topic/114496
2013年08月14日 03点08分 4
level 9
Excel process is terminated if only if the xlapp object is GCed.In the following code, if the ruby clean the xlapp object,
then Excel process is terminated.
xlapp.quit
xlapp = nil
GC.start # (*1)
But unfortunatelly, xlapp is not always GCed in GC.start(*1).
Sometimes xlapp may be GCed and sometimes not.
This is Ruby GC behavior.
If you want to terminate Excel process, use WIN32OLE#ole_free,
or WIN32OLE.ole_free.
xlapp.quit
WIN32OLE.ole_free(xlapp) # or xlapp.ole_free
xlapp = nil
GC.start
2013年08月14日 03点08分 5
能请教一个问题么 yaml json相关的 网上ruby资料实在是太少了 我这里暂时涉及到一个ruby的后台
2013年08月14日 03点08分
回复 齐刘海仙森 :用google查,就有答案.
2013年08月15日 10点08分
1