Skip to content
Advertisement

Python-docx – check if text in table has hidden attribute applied

I am new to Python and I am trying to check docx file for texts in table that have hidden attribute applied to them. If True, then I want to ignore that hidden text and replace any other text that matches my regex.

The thing is everything been good (replacement is working) until I added if i.font.hidden == True: condition thata seems to be incorrect.

The error I am getting: AttributeError: ‘int’ object has no attribute ‘font’

This is the code I have:

JavaScript

Advertisement

Answer

No need to access runs by index; you can iterate those directly:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement