View Single Post
 
Old 03-12-2024, 12:52 PM
Italophile Italophile is offline Windows 11 Office 2021
Expert
 
Join Date: Mar 2022
Posts: 341
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

To avoid using the clipboard:

Code:
 Sub CopyCurrentSectionToNewDoc()
  Dim Rng as Range, NewDoc as Document, currentSection as Long

  currentSection = Selection.Information(wdActiveEndSectionNumber)
  Set Rng = ActiveDocument.Sections(currentSection).Range
  Rng.MoveEnd wdCharacter, -1
  
  Set NewDoc = Documents.Add(Template:=ActiveDocument.AttachedTemplate.FullName, Visible:=True)
  
  ' Transfer contents into the output document, preserving the formatting
  NewDoc.Range.FormattedText = Rng.FormattedText
 
End Sub
Reply With Quote