乔山办公网我们一直在努力
您的位置:乔山办公网 > office365 > <em>vbs</em>批量将doc<em>另存为</em>txt;不要

<em>vbs</em>批量将doc<em>另存为</em>txt;不要

作者:乔山办公网日期:

返回目录:office365


Sub aa()
Selection.TypeText Text:="今天日记" & Format(Now, "yymmdd")
ActiveDocument.SaveAs2 FileName:="E:\" & "今天日记" & Format(Now, "yymmdd") & ".txt",FileFormat:=wdFormatText
ActiveWindow.Close
Application.Quit
End Sub
可以的话采纳吧!

代码是vbs代码,保存到任zhidao意位置使用:

'═════代═══码═══开═══始═════
set fso=CreateObject("Scripting.FileSystemObject")
set oWord=CreateObject("word.application")
oWord.Visible = False
set fs=fso.getfolder("c:\123").files
for each f in fs
ext=lcase(right(f.name,4))
if ext="docx" or ext=".doc" then
mnm=fso.GetParentFolderName(f.path)&"\"&fso.getbasename(f.path)
oWord.Documents.Open f.path
oWord.ActiveDocument.SaveAs2 mnm&".txt",2
oWord.ActiveDocument.close
end if
next
oWord.quit
msgbox "执行完毕!"
'Created By escortmnm from VBS团队
'═════代═══码═══结═══束═════

你的代码可以用的

Sub test()
Dim i
Dim Wrd As Range
i = Selection.Font.ColorIndex
For Each Wrd In ActiveDocument.Words
    If Wrd.Font.ColorIndex <> i Then Wrd.Copy
    SaveAsTxtFile '调用SaveAsTxtFile
Next Wrd
End Sub
Sub SaveAsTxtFile()
    Const 指定文件名 = "autosave01.txt"
    Documents.Add Template:="Normal", NewTemplate:=False, DocumentType:=0
    Selection.PasteSpecial Link:=False, DataType:=wdPasteText
    ActiveDocument.SaveAs2 FileName:=指定文件名, FileFormat:=wdFormatText, Encoding:=936
    ActiveDocument.Close
End Sub


识别一段文字,这段文字必须要有特别之处才行,说细一点吧?另存为文本文件,存在何处,文件名是什么,都要确定才好办呀

相关阅读

关键词不能为空
极力推荐
  • -office2013无法使用,此应用无法在你的电脑运行

  • 其实2013的office更新的东西是使之更适合zdwin8的触屏,我们其实试用2010版就已经足够了,在功能上和易用性上2013并没有比2010的好,所专以还是用2010的吧另外,你的2013装上了之后卡,估

ppt怎么做_excel表格制作_office365_word文档_365办公网