Set or replace the text of an existing shape (commonly a textbox). :param shape: The shape (textbox) whose text needs to be updated. :param text: The new text content. :param clear_first: Whether to clear existing paragraphs before adding.
(shape, text, clear_first=True)
| 1702 | shape.top = new_top |
| 1703 | |
| 1704 | def set_shape_text(shape, text, clear_first=True): |
| 1705 | """ |
| 1706 | Set or replace the text of an existing shape (commonly a textbox). |
| 1707 | |
| 1708 | :param shape: The shape (textbox) whose text needs to be updated. |
| 1709 | :param text: The new text content. |
| 1710 | :param clear_first: Whether to clear existing paragraphs before adding. |
| 1711 | """ |
| 1712 | text_frame = shape.text_frame |
| 1713 | text_frame.auto_size = MSO_AUTO_SIZE.NONE |
| 1714 | if clear_first: |
| 1715 | text_frame.clear() |
| 1716 | p = text_frame.add_paragraph() |
| 1717 | p.text = text |
| 1718 | |
| 1719 | def _set_run_font_color(run, rgb_tuple): |
| 1720 | """ |