Clean RTF files to any encoding text file type

本文介绍了一个使用VBS脚本批量转换Microsoft Word文档的方法,并允许用户指定目标文件类型及编码方式。脚本通过拖放文件的方式启动,实现了文档的批量转换与编码设置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. 'click
  2. If Wscript.Arguments.Count=0 Then  
  3. Msgbox "Drag and drop files on."
  4. Wscript.Quit  
  5. End If  
  6. 'start
  7. set wshell = CreateObject("Wscript.Shell")
  8. For i=0 to Wscript.Arguments.Count-1  
  9.     singlePath=singlePath+Wscript.Arguments(i)+"|"  
  10. next
  11. 'msgbox singlePath
  12. singlePaths = split(singlePath,"|")
  13. encodenum = inputbox("Please enter Encoding Code:")
  14. if not isnumeric(encodenum) then
  15.     msgbox "error!"
  16.     Wscript.Quit 
  17. end if
  18. filetype = inputbox("Please enter target file type:")
  19. if trim(filetype)="" then
  20.     msgbox "error!"
  21.     Wscript.Quit 
  22. end if
  23. Set myDocs = CreateObject("Word.Application")
  24.     Set myDoc = myDocs.Documents 
  25. for each singlePath in singlePaths
  26.     if singlePath = "" then
  27.         exit for
  28.     end if
  29.     'start winword
  30.     
  31.     myDocs.Visible = true
  32.     set myDoc1 = myDoc.Open(singlePath)
  33.     
  34.     myDocs.Application.Run "tw4winClean"
  35.     fname = left(myDocs.ActiveDocument.FullName,len(myDocs.ActiveDocument.FullName)-3)& filetype
  36.     'msgbox fname
  37.     myDocs.Application.ActiveDocument.SaveAs fname,2,False,""True,"",False,False, _
  38.          FalseFalseFalse,encodenum,False,False,wdCRLF
  39.     myDocs.ActiveDocument.close
  40. next
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值