PowerPoint 2007-在包含文本的表格,图表等上设置语言 [英] PowerPoint 2007 - Set language on tables, charts etc that contains text
问题描述
所以我有这个宏,它基本上扫描PowerPoint中的每张幻灯片并设置指定的语言.效果很好.但是,它会跳过不是文本框的容器.我希望将这种语言应用于表格,smartart,图表等.基本上任何可能包含文本的内容.
So I've got this macro that basically scans each slide in PowerPoint and sets the specified language. Works great. Howerver, it skips containers that aren't text boxes. I'd like it to apply the language on tables, smartart, charts etc. Basically anything that may contain text.
这甚至有可能吗?这是当前代码:
Is this even possible? This is the current code:
Public Sub changeLanguage()
On Error Resume Next
'lang = "English"
lang = "Norwegian"
'Determine language selected
If lang = "English" Then
lang = msoLanguageIDEnglishUK
ElseIf lang = "Norwegian" Then
lang = msoLanguageIDNorwegianBokmol
End If
'Set default language in application
ActivePresentation.DefaultLanguageID = lang
'Set language in each textbox in each slide
For Each oSlide In ActivePresentation.Slides
Dim oShape As Shape
For Each oShape In oSlide.Shapes
oShape.Select
oShape.TextFrame.TextRange.LanguageID = lang
Next
Next
End Sub
推荐答案
是的,虽然在PowerPoint中不是那么直观,但是可以做到.基本上,有3种主要类型的形状(简单,分组和表格).这段代码将检查所有内容:
Yeah, it's not all that intuitive in PowerPoint, but it can be done. Basically, there are 3 major types of shapes (simple, grouped and tables). This code will check them all:
Public Sub changeLanguage()
On Error Resume Next
Dim gi As GroupShapes '<-this was added. used below
'lang = "English"
lang = "Norwegian"
'Determine language selected
If lang = "English" Then
lang = msoLanguageIDEnglishUK
ElseIf lang = "Norwegian" Then
lang = msoLanguageIDNorwegianBokmol
End If
'Set default language in application
ActivePresentation.DefaultLanguageID = lang
'Set language in each textbox in each slide
For Each oSlide In ActivePresentation.Slides
Dim oShape As Shape
For Each oShape In oSlide.Shapes
'Check first if it is a table
If oShape.HasTable Then
For r = 1 To oShape.Table.Rows.Count
For c = 1 To oShape.Table.Columns.Count
oShape.Table.Cell(r, c).Shape.TextFrame.TextRange.LanguageID = lang
Next
Next
Else
Set gi = oShape.GroupItems
'Check if it is a group of shapes
If Not gi Is Nothing Then
If oShape.GroupItems.Count > 0 Then
For i = 0 To oShape.GroupItems.Count - 1
oShape.GroupItems(i).TextFrame.TextRange.LanguageID = lang
Next
End If
'it's none of the above, it's just a simple shape, change the language ID
Else
oShape.TextFrame.TextRange.LanguageID = lang
End If
End If
Next
Next
End Sub
这篇关于PowerPoint 2007-在包含文本的表格,图表等上设置语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!