vbA操作word文档自动生成txt文件 ,求,多谢

fieldset{padding:10px;}

vbA操作word文档自动生成txt文件 ,求,谢谢一个word文档有很多行数据(由英语和汉字组成),要每9行数据生成一个txt文件,txt文件名依次按生成顺序名命为“文件1”“文件2”…… 。(注:如果最后的数据不够9行的,也要把剩下的数据自动生成一个txt文件) 谢谢各位——解决方案——————————————————–把fs拉出循环体了VB code

Sub test()    Dim fs As Object    Dim a    Dim doc As Document    Dim txtPath, txtFullName As String    Dim i, docLines As Long        txtPath = "d:\&; '文档保存路径    Set doc = Documents("11.doc")    Selection.HomeKey Unit:=wdStory    docLines = doc.BuiltInDocumentProperties(wdPropertyLines).Value        Set fs = CreateObject("Scripting.FileSystemObject")    For i = 1 To Round(docLines / 9 + 0.5)        txtFullName = txtPath & "文件" & i & ".txt"        Set a = fs.CreateTextFile(txtFullName, True)                Selection.GoTo What:=wdGoToLine, Which:=wdGoToFirst, Count:=9 * (i - 1) + 1, Name:=""        Selection.MoveDown Unit:=wdLine, Count:=9, Extend:=wdExtend                a.WriteLine (Selection.Text)        a.Close        Set a = Nothing    Next    Set fs = Nothing    End Sub天不负;卧薪尝胆,三千越甲可吞吴。

vbA操作word文档自动生成txt文件 ,求,多谢

相关文章:

你感兴趣的文章:

标签云: