VBS implements DOC to text document code _vbs

Source: Internet
Author: User
Open Notepad Input:
Copy Code code 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\\ to text document \command\", "Wscript.exe C:\WINDOWS\doc2txt.vbe "
Notepad Editor
CreateObject ("Wscript.Shell"). RegWrite "hkcu\docfile\shell\\ to text document \command\", "Wscript.exe C:\WINDOWS\doc2txt.vbe %1
The above content is saved as *. VBS, after running, right click on the doc file, you can see the "Convert to text Document" Item, click on it can be quickly converted to a text document.
The above content is tested under WIN2000 plus WORD2003.
I found in the trial process, the script to write the meter after the Doc right button sometimes does not appear conversion menu, you can change the second script docfile to *, that is, in all types of files right-click menu to add conversion items.
Alternatively, you can put the doc2txt.vbe file in the "SendTo" folder and right-click on the doc file to select "Send to ~doc2txt.vbe".
This method can also convert files such as html,rtf to text documents.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.