两件事:1)这是在VBA中,但应该很容易移植到C#和VSTO;2)“文本更改”的事情有点棘手。我可以告诉你“你在一个标题框中吗”-其余的都是琐碎的。它与找到原始状态和任何更改有关。可能我还没有做到。
要在PPT VBA中钩住选择更改,您需要一个类和一个模块。在课堂上,写下:
Public WithEvents PPTEvent As Application
Private Sub PPTEvent_WindowSelectionChange(ByVal Sel As Selection)
With Sel
If .Type = ppSelectionText Then
Dim sh As Shape: Set sh = .ShapeRange(1)
If sh.Type = msoPlaceholder Then
originalText = sh.TextFrame.Text
Dim placeHolderType As Integer
placeHolderType = sh.PlaceholderFormat.Type
If placeHolderType = ppPlaceholderTitle Then
MsgBox "this is a title placeholder"
End If
End If
End If
End With
End Sub
将类命名为“clsPPTEvents”。然后在任何模块中,输入以下内容:
Public newPPTEvents As New clsPPTEvents
Sub StartEvents()
Set newPPTEvents.PPTEvent = Application
End Sub
Sub EndEvents()
Set newPPTEvents.PPTEvent = Nothing
Set newPPTEvents = Nothing
End Sub
按
F5