【问题标题】:Dropdown list (combobox) disappears when saving PowerPoint 2010 document保存 PowerPoint 2010 文档时下拉列表(组合框)消失
【发布时间】:2014-05-22 15:15:27
【问题描述】:

我在 Power Point 2010 中创建了一个下拉列表,在保存文档之前效果很好。我在 VBA 中使用了以下代码:

Sub AddItemsToSelectedListBox()

Dim oShape As Shape

Set oShape = ActiveWindow.Selection.ShapeRange(1)

With oShape.OLEFormat.Object

' Add items to the list

.AddItem ("Good")

.AddItem ("Better")

.AddItem ("Best")

' You could work with other properties of the list or combo box here as well

End With

End Sub

f5 + 关闭。

通过查看模式,下拉列表效果很好。但是,如果我保存我的 power point 文档(以 .pptm 格式)并重新打开演示文稿,则列表不再下拉。如果我输入 VBA,代码如下所示:

Sub AddItemsToSelectedListBox()

Dim oShape As Shape

Set oShape = ActiveWindow.Selection.ShapeRange(1)

With oShape.OLEFormat.Object

' Add items to the list

.AddItem ("Good")

.AddItem ("Better")

.AddItem ("Best")

' You could work with other properties of the list or combo box here as well

End With

End Sub

Private Sub ComboBox1_Change()

End Sub

ComboBox_Change() 部分是新的。 (为什么?) 有谁知道,如何生成一个在保存过程中幸存下来的下拉列表? 非常感谢你!!

【问题讨论】:

    标签: vba drop-down-menu powerpoint office-2010


    【解决方案1】:

    当您双击组合框进入 VBE 时,将添加 _Change 子例程。

    如果您从模块中的子例程加载组合框,当您保存并重新打开时,它似乎不会保留值。

    如果您从框本身的事件中加载组合框,它似乎可以按预期工作。

    例如:

    Private Sub ComboBox1_GotFocus()
    
    Dim oShape As Shape
    
    Set oShape = ActivePresentation.Slides(1).Shapes("ComboBox1")
    
    With oShape.OLEFormat.Object
    .Clear
    
    ' Add items to the list
    
    .AddItem ("Good")
    
    .AddItem ("Better")
    
    .AddItem ("Best")
    
    ' You could work with other properties of the list or combo box here as well
    
    End With
    End Sub
    

    【讨论】:

    • 但如果我添加更多组合框(combobox1;combobox3;combobox5),则只有最后一个组合框被保存,并且在重新打开演示文稿时有效。其他人都走了:-(
    • 其他人是走了还是空了?
    • 其他都是空的。输入代码,看到CB2里面是CB1 + Private Sub ComboBox2_Change() End Sub的代码。在 CB3 中也是如此。它只保存第一个 ComboBox 代码!?
    • 为什么不编辑您的原始帖子以显示您正在使用的新代码......这可能有助于理解问题。
    猜你喜欢
    • 2016-08-24
    • 2019-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-20
    相关资源
    最近更新 更多