【发布时间】:2014-12-17 09:55:27
【问题描述】:
我是 powerpoint vba 的新手。我想要做的就是编写一小段代码,它允许我根据通过单击按钮所做的选择来更改幻灯片的布局。
我的代码的问题是我得到了 runtimeerror 438。
这是我所拥有的:
Private Sub CommandButton1_Click() 'Klick Button 1'
ActivePresentation.Slides(10).Delete
ActivePresentation.Slides(9).Delete
ActivePresentation.Slides(8).Delete
Dim x As Integer
For x = 1 To 100
With ActivePresentation.Slides(x)
If .CustomLayout = .CustomLayout(8) Then
Set .CustomLayout = .CustomLayout(12)
End If
End With
Next x
End Sub
编辑:错误描述是:“对象不支持此属性或方法”
非常感谢任何形式的帮助和建设性意见。
编辑二:我现在明白 .CustomLayout 返回一个自定义布局。但是我如何设置/更改某些幻灯片的布局?我需要如何解决它? 非常感谢
编辑 III:我仍然没有解决方案,我现在真的很沮丧。我猜你们是我最后一次寻求帮助的机会。所以现在又是我的代码:
Dim x As Integer
For x = 7 To 100
If ActivePresentation.Slides(x).CustomLayout = ActivePresentation.Designs(1).SlideMaster.CustomLayouts(8) Then ActivePresentation.Slides(x).CustomLayout = ActivePresentation.Designs(1).SlideMaster.CustomLayouts(12)
End If
Next x
我仍然得到上面描述的运行时错误。我怎样才能摆脱它并使我的代码工作? 非常感谢!
【问题讨论】:
-
能否还包括与此错误相关的错误描述,以及引发此错误的 LOC?
-
当然!因为我是德国人,所以我得到了德语的错误描述。尽量翻译好:“对象不支持这个属性或方法”
-
@Ruben 你用的是什么版本的Office?
-
@razcor 我正在使用 Powerpoint 2010 我现在尝试使用您建议的代码。不幸的是,我仍然收到相同的错误消息
-
@Ruben 你的 If 块是错误的,我添加了一个正确的块来编辑我的答案。
标签: vba powerpoint