为 powerpoint 在宏结束时存储值

Storing Values When a Macro Ends for powerpoint

我指的是以下解释: https://docs.microsoft.com/en-us/office/vba/word/concepts/miscellaneous/storing-values-when-a-macro-ends

如何修改以下代码以在 powerpoint 中使用? 将 ActiveDocument 替换为 ActivePresentaiton 似乎并不能解决问题。

Sub AddDocumentVariable()
 ActiveDocument.Variables.Add Name:="Age", Value:=12
End Sub
Sub UseDocumentVariable()
 Dim intAge As Integer
 intAge = ActiveDocument.Variables("Age").Value
End Sub

您不能直接将 ActiveDocument 替换为 ActivePresentaitonActivePresentaiton 没有 .Variables 属性.

我对 Powerpoint 的建议是将您的数据保存在 .txt 文件中,以便您以后可以访问它,或者将您的变量添加到注册表中。阅读 this link 此处。

我建议您做更多研究并发布您的代码,以便我们更好地帮助您理解您的整个问题。

您如何存储信息将取决于要存储多少信息以及您以后需要用它做什么。虽然我不建议使用注册表,但文本文件会成为可以附加的良好永久记录。

或者您可以将信息存储在 .Tags 中:

Sub AddTag()
  ActivePresentation.Tags.Add "Name", "12"
End Sub

Sub ReadTag()
  MsgBox ActivePresentation.Tags("Name")
End Sub