If Selection.Find.Found = True Then
Selection.HomeKey unit:=wdLine
Selection.MoveDown unit:=wdParagraph, Extend:=wdExtend
Set fs = CreateObject("Scripting.FileSystemObject")
Set sr = fs.CreateTextFile("D:\" & txtname & ".txt", True)
sr.Writeline (Selection.Text)
sr.Close
输出到TXT后 末尾总会多出三个字符 如果用 Write则只多出一个字符 猜测可能是段落末尾的回车 求教怎么只选择段落文字。。 由于需要对输出到txt的字符要求必须完全准确 谢谢。。
vba word 输出TXT问题
答案:2 悬赏:0 手机版
解决时间 2021-03-19 12:48
- 提问者网友:捧腹剧
- 2021-03-19 08:21
最佳答案
- 五星知识达人网友:动情书生
- 2021-03-19 09:23
用Write吧,为了避免多选一个回车,那就再加一句moveleft,最后改成
Selection.HomeKey unit:=wdLine
Selection.MoveDown unit:=wdParagraph, Extend:=wdExtend
Selection.MoveLeft wdCharacter, 1, wdExtend
Set fs = CreateObject("Scripting.FileSystemObject")
Set sr = fs.CreateTextFile("D:\" & TxtName & ".txt", True)
sr.Write (Selection.Text)
sr.Close
Selection.HomeKey unit:=wdLine
Selection.MoveDown unit:=wdParagraph, Extend:=wdExtend
Selection.MoveLeft wdCharacter, 1, wdExtend
Set fs = CreateObject("Scripting.FileSystemObject")
Set sr = fs.CreateTextFile("D:\" & TxtName & ".txt", True)
sr.Write (Selection.Text)
sr.Close
全部回答
- 1楼网友:由着我着迷
- 2021-03-19 11:01
用write吧,为了避免多选一个回车,那就再加一句moveleft,最后改成
selection.homekey unit:=wdline selection.movedown unit:=wdparagraph, extend:=wdextend selection.moveleft wdcharacter, 1, wdextend set fs = createobject("scripting.filesystemobject") set sr = fs.createtextfile("d:\" & txtname & ".txt", true) sr.write (selection.text) sr.close我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯