Powerpoint VBA运行时错误438(简单)
我对powerpoint vba一无所知。我只想写一段代码,让我可以根据点击按钮所做的选择来更改幻灯片的布局 我的代码的问题是我得到了运行时错误438 以下是我所拥有的:Powerpoint VBA运行时错误438(简单),vba,powerpoint,Vba,Powerpoint,我对powerpoint vba一无所知。我只想写一段代码,让我可以根据点击按钮所做的选择来更改幻灯片的布局 我的代码的问题是我得到了运行时错误438 以下是我所拥有的: Private Sub CommandButton1_Click() 'Klick Button 1' ActivePresentation.Slides(10).Delete ActivePresentation.Slides(9).Delete ActivePresentation.Slides(8).Delete
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
编辑:错误描述为:“对象不支持此属性或方法”
我非常感谢任何形式的帮助和建设性的投入
编辑II:我现在明白了。CustomLayout返回一个自定义布局。但是如何设置/更改特定幻灯片的布局?我需要如何处理它?
多谢各位
编辑三:我仍然没有解决办法,我现在真的很沮丧。我想你们是我最后一次求助的机会了。所以现在我的代码是:
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
我仍然得到上面描述的运行时错误。我怎样才能摆脱它,使我的代码工作?
多谢各位 CustomLayout是定义自定义布局的对象,在界面中它们是: 在vba中,可以使用ActivePresentation.Designs.SlideMaster对象访问它们 显然,每个幻灯片对象只能应用一个CustomLayout,您可以使用CustomLayout属性访问它 因此,如果要使用CustomLayout n更改幻灯片1 CustomLayout。3你必须做:
ActivePresentation.Slides(1).CustomLayout = ActivePresentation.Designs(1).SlideMaster.CustomLayouts(3)
见:
关于代码,必须在If块comaprison中使用名称,因此:
If ActivePresentation.Slides(x).CustomLayout.Name = ActivePresentation.Designs(1).SlideMaster.CustomLayouts(3).Name Then
ActivePresentation.Slides(x).CustomLayout = ActivePresentation.Designs(1).SlideMaster.CustomLayouts(7)
End If
请您也包括与此错误相关的错误描述,以及引发此错误的LOC?当然!因为我是德国人,所以我得到了德语的错误描述。尝试尽可能好地翻译:“对象不支持此属性或方法”@Ruben您使用的Office版本是什么?@razcor我正在使用Powerpoint 2010我现在尝试使用您建议的代码。不幸的是,我仍然得到同样的错误Message@Ruben如果你的块是错误的,我在编辑我的答案时添加了一个正确的块。