# -*- coding: utf-8 -*-
"""
Created on Wed Aug 11 14:24:27 2021

@author: lhkha
"""
from docx import Document
from docx.enum.style import WD_STYLE_TYPE
from docx.shared import Inches, Pt
import docx, os, glob

finaldocname = 'combination.docx'
finaldoc=docx.Document()
docstoworkon = glob.glob('*.docx')
if finaldocname in docstoworkon:
    docstoworkon.remove(finaldocname)
    
doc_out = Document()
for f in docstoworkon:
    doc=docx.Document(f)
    styles = doc.styles
    #docStyle = docx.Styles
    for para in doc.paragraphs:
        p = doc_out.add_paragraph()
        for run in para.runs:
            r = p.add_run(run.text)
            if run.bold:
                r.bold = True
            if run.italic:
                r.italic = True
            if run.underline:
                r.underline = True
            r.font.name = run.font.name  #None Value Why?
            r.font.size = run.font.size  #None Value
            r.style = run.style
        p.alignment = para.alignment
    if doc.settings.odd_and_even_pages_header_footer:
        doc_out.settings.odd_and_even_pages_header_footer = True
# =============================================================================
#     doc_out.settings.element = doc.settings.element                          # document-level settings
# =============================================================================
    doc_out.add_page_break()
# =============================================================================
#         p.styles.baseStyle = para.styles.baseStyle
#         p.characterStyle = para.characterStyle
#         p.paragraphStyle = para.paragraphStyle
# =============================================================================
        
# =============================================================================
#     doc_out.BaseStyle = doc.BaseStyle
#     doc_out.characterStyle = doc.characterStyle
#     doc_out.paragraphStyle = doc.paragraphStyle
#     #doc_out.baseStyle = doc.baseStyle
# =============================================================================
        
                
doc_out.save('C:/Users/lhkha/.spyder-py3/lekhanh/Example_Input/combination.docx')
StarcoderdataPython