Tách 1 trang trong Word thành 1 file

Nơi trao đổi về VBA (Visual Basic for Application), lập trình cho ứng dụng Microsoft Office, AutoCAD...

Moderator: tungblt

Post Reply
vantoanht01
Posts: 1
Joined: Tue 04/03/2014 9:10 pm

Tách 1 trang trong Word thành 1 file

Post by vantoanht01 »

Các cao thủ giúp cách xử lý em với
Cần tách Auto 1 trang trong Word thành 1 file riêng biệt

Sub SlpipFile()
Dim i As Long
Application.ScreenUpdating = False
ChangeFileOpenDirectory ActiveDocument.Path
Selection.Find.ClearFormatting
With Selection.Find
.Text = "^k"
.Forward = True
.Wrap = wdFindContinue
End With
ActiveDocument.Range(0, 0).Select
Do Until Selection.Find.Execute = False
i = i + 1
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.MoveDown Unit:=wdParagraph, Count:=999999999, Extend:=wdExtend
Selection.Cut
Selection.TypeBackspace
ActiveDocument.SaveAs "File_" & VBA.Format(i, "000") & ".doc", 0
ActiveDocument.Close
Documents.Add DocumentType:=wdNewBlankDocument
Selection.Paste
ActiveDocument.Range(0, 0).Select
Loop
ActiveDocument.SaveAs "File_" & VBA.Format(i + 1, "000") & ".doc", 0
Application.ScreenUpdating = True
End Sub
Post Reply

Return to “Visual Basic for Application (VBA)”