2014-05-22 3 views
0

문서를 저장하기 전에 Powerpoint 2010에서 드롭 다운 목록을 작성했습니다. VBA에서 다음 코드를 사용했습니다.PowerPoint 2010 문서를 저장할 때 드롭 다운 목록 (콤보 상자)이 사라집니다.

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 + close.

보기 모드로 이동하면 드롭 다운 목록이 잘 작동합니다. 그러나 파워 포인트 문서를 .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() 부분은 새로운 기능입니다. (왜?) 저장 프로세스에서 살아남은 드롭 다운 목록을 생성하는 방법을 아는 사람이 있습니까? 대단히 감사합니다 !!

답변

0

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 
+0

하지만 더 많은 콤보 (콤보 상자, combobox3, combobox5)를 추가하면, 마지막 콤보가 저장되는 프레젠테이션이 재개되어 작동합니다. 다른 사람이 사라 졌어요 :-( – user3665640

+0

다른 사람이 사라 졌거나 비어 있습니까? –

+0

다른 사람이 비어 있습니다. 코드를 입력하면 CB2의 코드가 CB1 + 개인용 ComboBox2_Change() 코드 End Sub 그리고 CB3에서는 첫 번째 콤보 상자 코드 만 저장합니다.? – user3665640