ms-word

How to print text and certain specified tags of XML file using BeautifulSoup

How to print text and certain specified tags of XML file using BeautifulSoup Question: I’m parsing the XML of a Microsoft Word .docx file with BeautifulSoup. I’d like to be able to extract the text of the XML file while still printing certain tags that I choose. I can get the text of the file …

Total answers: 1

how to export images to word file?

how to export images to word file? Question: I am working on a script which saves images to word file. I have been able to create a function to export images. def exp_images(): #export images to word file document = Document() paragraph = document.add_paragraph() script = paragraph.add_run() script.add_text(‘This is a test sentence’) script.add_picture(‘image1.png’, width=Inches(6.5)) document.save(‘demo.docx’) …

Total answers: 1

How do I change the font color in the cell under the table in the Word document?

How do I change the font color in the cell under the table in the Word document? Question: I tried to use document.styles[‘Normal’].font.color.rgb = RGBColor(255, 0, 255) to change the font color in the table, but it made all of the colors change in the fonts of the table. Am I missing something? import docx …

Total answers: 1

Getting the List Numbers of List Items in docx file using Python-Docx

Getting the List Numbers of List Items in docx file using Python-Docx Question: When I am accessing paragraph text it does not include the numbering in a list. Current code: document = Document("C:/Foo.docx") for p in document.paragraphs: print(p.text) List in docx file: I am expecting: (1) The naturalization of both … (2) The naturalization of …

Total answers: 3

Python docx module ModuleNotFoundError

Python docx module ModuleNotFoundError Question: I am a windows 7 user with MS-Office 2016 and python 3.6. I recently found out that you can write word documents with python. I looked on how to do that I installed the docx module: pip install docx But whenever i try to import the docx module i get …

Total answers: 3

Replace String in XML while keeping function

Replace String in XML while keeping function Question: I’m trying to generate a Word document with data based on a template using python-docx. For the most part, I’ve managed to work out something. However, my document has some conditions that I am trying to fulfil, namely I need to generate certain data only in the …

Total answers: 1

How to extract image from table in MS Word document with docx library?

How to extract image from table in MS Word document with docx library? Question: I am working on a program that needs to extract two images from a MS Word document to use them in another document. I know where the images are located (first table in the document), but when I try to extract …

Total answers: 2

Make last paragraph – active pointer

Make last paragraph – active pointer Question: I am trying to write my research work in markdown, and it’s required by my institution to submit it in Word doc format. I decided to use python-docx package to automate this task. However, I am struggling with some specific task, like adding data to end of the …

Total answers: 1

Add page number using python-docx

Add page number using python-docx Question: I am trying to add a page number in the footer of a word doc using python-docx. So far, I haven’t been able to find how to do so. This question address how to find a page number (or how you cannot). This one talks about creating a template …

Total answers: 7