Get the App
SLTechnology News&Howtos  ›  Development  › 

How to convert DOC to text document by VBS

Shulou Source: shulou.com Published: 2022-06-03 08:39:20 11月15日 Update

This article mainly introduces VBS how to achieve DOC into text documents, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Open notepad and enter:

The 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\ doc2txt.vbe".

Notepad editor

Createobject ("wscript.shell"). Regwrite "HKCU\ docfile\ Shell\\ convert to text document\ Command\", "wscript.exe C:\ WINDOWS\ doc2txt.vbe"

Notepad editor

Createobject ("wscript.shell") .regwrite "HKCU\ docfile\ Shell\\ convert to text document\ Command\", "wscript.exe C:\ WINDOWS\ doc2txt.vbe% 1"

Save the above content as * .VBS, after running, right-click on the doc file, you can see the "convert to text document" item, click to quickly convert to a text document.

The above content passed the test under WIN2000 plus WORD2003.

In the course of the experiment, I found that the DOC right button sometimes does not appear the conversion menu after the script written into the note table is run. You can change the docfile in the second script to *, which is to add conversion items to the right menu of all types of files.

Or put the doc2txt.vbe file into the "sendto" folder, right-click on the doc file and select "send to ~ doc2txt.vbe", which can also be converted.

This method can also convert files such as HTML,RTF into text documents.

Thank you for reading this article carefully. I hope the article "how to convert VBS into text documents" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Files articles notepad content scripts menus runs code values interests and at the same time folders more friends knowledge types editing industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Linux Shulou Tech Info macOS Huawei