Macro Sub BreakOnSection()

Fermé
Alice555 Messages postés 11 Date d'inscription vendredi 16 septembre 2016 Statut Membre Dernière intervention 20 juillet 2018 - 7 mars 2017 à 08:34
Bonjour,

je dois établir une fusion de documents avec une liste Excel.
afin d'établir des documents séparés, j'ai besoin d'une macro Sub BreakOnSection().
malheureusement après fusion le document n'a pas gardé sa mise en page. il devrait sortir sur 2 pages maxi et se retrouve sur 3 pages, les marges sont plus grandes et même la police est modifiée.
avez vous possibilité de modifier cette macro pour bloquer la mise en page définie?

voici la macro:
Sub BreakOnSection()
' Used to set criteria for moving through the document by section.
Application.Browser.Target = wdBrowseSection

'A mailmerge documents ends with a section break next page.
'Subtracting one from the section count stop error message.
For i = 1 To ((ActiveDocument.Sections.Count) - 1)

'Select and copy the section text to the clipboard
ActiveDocument.Bookmarks("\Section").Range.Copy

'Create a new document to paste text from clipboard.
Documents.Add
Selection.Paste

' Removes the break that is copied at the end of the section, if any.
Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
ChangeFileOpenDirectory "C:\"
DocNum = DocNum + 1
ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"
ActiveDocument.Close
' Move the selection to the next section in the document
Application.Browser.Next
Next i
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub

je n'arrive pas à vous transmettre le modèle pour la fusion ni le tableau!!

merci de votre aide
A voir également: