Code for converting Doc to text document in vbs

Source: Internet
Author: User

Open notepad and enter: CopyCode 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, Rev (docpath ,"\"))
Txtpn = PT & left (docfile. Name, Rev (docfile. Name, ".") & "TXT"
Invalid Doc uments. Open docpath, false
Using Doc uments (docpath). Activate
W. activedocument. saveas txtpn, 2
W. activedocument. Close
W. Quit
Set W = nothing

Save it to "C: \ WINDOWS \ doc2txt. VBE ".
Notepad editing
Createobject ("wscript. Shell"). regwrite "hkcu \ docfile \ shell \ convert to text document \ command \", "wscript.exe c: \ windows \ doc2txt. VBE"
Notepad editing
Createobject ("wscript. Shell"). regwrite "hkcu \ docfile \ shell \ convert to text document \ command \", "wscript.exe c: \ windows \ doc2txt. VBE % 1"
Save the preceding content as *. vbs. After running the command, right-click the DOC file and you will see the "convert to text document" item. Click it to quickly convert it to text document.
The above content is tested in Win2000 and word2003.
During the test, I found that after the script written to the test table is run, the conversion menu is sometimes not displayed by right-clicking the doc. You can change the docfile In the second script *, add a conversion item in the context menu of all types of files.
Alternatively, place the doc2txt. VBE file in the "sendto" folder, right-click the DOC file, and select "send ~ Doc2txt. VBE ", which can also be converted.
This method can also convert HTML, RTF, and other files into 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.