Forum

How to preserve sou...
 
Notifications
Clear all

How to preserve source formatting after file split by the macro

3 Posts
2 Users
0 Reactions
86 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:22 pm
(@sunnykow)
Posts: 1417
Noble Member
 

Hi David

This is a MS Word issue and not related to Excel.

So this is not the correct forum to post the question.

Sunny

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

Tks Sunny, sorry the intruption..

 
Posted : 22/06/2018 1:28 am
Share: