Forum

How to preserve sou...
 
Notifications
Clear all

How to preserve source format after the file split

2 Posts
1 Users
0 Reactions
64 Views
(@david_ng)
Posts: 310
Reputable Member
Topic starter
 

Sub Split_()
Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter < Letters
    Application.ScreenUpdating = False
    With Selection
        .HomeKey Unit:=wdStory
        .EndKey Unit:=wdLine, Extend:=wdExtend
        .MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
    End With
    sName = Selection
    DocName = "C:Documents" & sName & ".docx"
    ActiveDocument.Sections.First.Range.Cut
    Documents.Add
    Selection.Paste
    'With Selection
    '    .Paste
    '    .HomeKey Unit:=wdStory
    '   .MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
    '   .Delete
    'End With
   ActiveDocument.SaveAs2 FileName:=DocName, _
    FileFormat:=wdFormatXMLDocument, _
   CompatibilityMode:=14
   ActiveWindow.Close
    Counter = Counter + 1
    Application.ScreenUpdating = True
Wend
End Sub

 
Posted : 21/06/2018 11:01 pm
(@david_ng)
Posts: 310
Reputable Member
Topic starter
 

Pls help modified the VB

 
Posted : 21/06/2018 11:10 pm
Share: