2015-08-22 76 views
4

是否可以让Powerpoint 2013自动适应文字?我正在使用python-pptx,我可以将该选项设置为autofit,但最初它不起作用。如果我调整文本框的大小或随后更改“包装”等设置,则自动装配工作。但是,我不能从python-pptx那样做。我需要选择第一次添加文本时的工作。如何让Powerpoint自动适应文字

我认为这是PowerPoint中的一个错误,微软不打算修复,但希望我错了。

+1

发现作为一种变通方法,我可以隐藏在演示文稿中的每张幻灯片,然后再次显示它,使用VB宏。这解决了这个问题,但不必这样做很好。 – resigned

+0

您应该将其作为您自己的答案张贴,我猜。感谢您的更新。 – Cilvic

回答

2

下面是一个简单的代码,它将文本框中的文本换行而不需要调整文本框的大小。我希望这有帮助。

from pptx import Presentation 
from pptx.util import Inches 

prs = Presentation() 
titleLayout = prs.slide_layouts[0] 
slide = prs.slides.add_slide(titleLayout) 

textBox = slide.shapes.add_textbox(Inches(3.5), Inches(0.5),Inches(3), Inches(3.0)) 
textFrame = textBox.text_frame 
textFrame.word_wrap = True 
textParagraph = textFrame.add_paragraph() 
textParagraph.text = "This is a word_wrap example. The words are wrapped within the textframe" 

prs.save("C:\OSGeo4W\GPSPictureManager\Tests\PptxWordWrapTest.pptx")#specify path for new pptx file 

更多细节可以在http://python-pptx.readthedocs.io/en/latest/api/text.html#textframe-objects

相关问题