Code of transforming doc into text document by vbs

Time:2020-10-19

Open Notepad input:

Copy codeThe code is as follows:
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 

Save to “C: Windows / DOC2” txt.vbe ”。
Notepad editor
createobject(” wscript.shell “). Regwrite” HKCU / docfile / shell \ \ to text document wscript.exe  C:\WINDOWS\doc2 txt.vbe “
Notepad editor
createobject(” wscript.shell “). Regwrite” HKCU / docfile / shell \ \ to text document wscript.exe  C:\WINDOWS\doc2 txt.vbe  %1″
The above content is saved as *. VBS. After running, right-click on the doc file to see the item “convert to text document”. Click to quickly convert it to a text document.
The above contents have passed the test under WIN2000 and word2003.
During the experiment, I found that after the script written into the annotation table runs, the doc right-click sometimes does not appear the conversion menu. You can change the docfile in the second script to * to add conversion items in the right-click menu of all types of files.
Or add DOC2 txt.vbe Put the file in the “SendTo” folder, right-click on the doc file and select “send to ~ DOC2” txt.vbe ”Can also be converted.
This method can also convert HTML, RTF and other files into text documents.