作者:乔山办公网日期:
返回目录: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
识别一段文字,这段文字必须要有特别之处才行,说细一点吧?另存为文本文件,存在何处,文件名是什么,都要确定才好办呀