Board logo

标题: doc转换为txt [打印本页]

作者: hjkk123     时间: 2008-6-3 19:19    标题: doc转换为txt

ON ERROR RESUME NEXT  
set args=wscript.arguments  
arg=args(0)  
set w=createobject("word.application")  
set fso=createobject("scripting.filesystemobject")  
set docfile=fso.getfile(arg)  
docpath=docfile.path  
pt=left(docpath,Instrrev(docpath,"\"))  
txtpn=pt&left(docfile.name,instrrev(docfile.name,"."))&"txt"  
w.documents.open docpath,,,,,,,,,,,false  
w.documents(docpath).activate  
w.activedocument.saveas txtpn,2  
w.activedocument.close  
w.quit  
set w=nothing

保存到“C:\WINDOWS\doc2txt.vbe”。
记事本编辑
createobject("wscript.shell").regwrite "HKCU\docfile\Shell\\转为文本文档\Command\","wscript.exe C:\WINDOWS\doc2txt.vbe %1"
以上内容保存为*.VBS,运行后,在doc文件上右击,就可以看到“转换为文本文档”项,点击就可以快速转换为文本文档。