Хотя прошло немного времени ... пришло сюда с https://superuser.com/questions/432366/how-do-i-change-the-language-of-all-powerpoint-slides-at-once. Поскольку я предпочитаю работать с Python, версия Python, использующая пакет win32com
, будет выглядеть так:
infile_name = 'drive:/path/to/in.pptx'
outfile_name = 'drive:/path/to/out.pptx'
target_language = 1031 # find in language list, here German
import time
import win32com.client
ppt = win32com.client.Dispatch('PowerPoint.Application')
ppt.Visible = True
presentation = ppt.Presentations.Open(infile_name)
def change_all_subshapes(target_shape, language_id):
if target_shape.HasTextFrame:
target_shape.TextFrame.TextRange.languageID = language_id
if target_shape.HasTable:
for r in range(1, target_shape.Table.Rows.Count + 1):
for c in range(1, target_shape.Table.Columns.Count + 1):
target_shape.Table.Cell(r, c).Shape.TextFrame.TextRange.LanguageID = language_id
# look the constants msoGroup and msoSmartArt up
if target_shape.Type in [6, 24]:
for i in range(1, target_shape.GroupItems.Count + 1):
change_all_subshapes(target_shape.GroupItems.Item(i), language_id)
# necessary: hopefully ppt is open after a second
time.sleep(1)
print('all slides')
for i in range(1, presentation.Slides.Count + 1):
for j in range(1, presentation.Slides(i).Shapes.Count + 1):
change_all_subshapes(presentation.Slides(i).Shapes(j), target_language)
print('master shapes')
for i in range(1, presentation.SlideMaster.CustomLayouts.Count + 1):
for j in range(1, presentation.SlideMaster.CustomLayouts(i).Shapes.Count + 1):
change_all_subshapes(presentation.SlideMaster.CustomLayouts(i).Shapes(j), target_language)
presentation.SaveAs(outfile_name)
presentation.Close()
ppt.Quit()