带点击的 Powerpoint 电子邮件表格

Powerpoint email form with click

您好,我正在尝试构建一个 VBA 代码,以便在表单完成后自动发送已完成表单的副本。我目前有这个表格,我能够为 word 文档编写以下代码:

Private Sub CommandButton1_Click()
Dim OL              As Object
Dim EmailItem       As Object
Dim Doc             As Document
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
Doc.Save

With EmailItem
.Subject = "SUBJECT LINE"
.Body = "BODY MESSAGE" & vbCrLf & _
"SECOND LINE BODY MESSAGE" & vbCrLf & _
"THIRD LINE BODY MESSAGE"
.To = "Receiver Email"
.Importance = olImportanceNormal
.Attachments.Add Doc.FullName
.Send
End With

Application.ScreenUpdating = True

Set Doc = Nothing
Set OL = Nothing
Set EmailItem = Nothing
End Sub

这对 word 文档工作得很好,但现在我必须在 powerpoint 中执行以下操作。我尝试使用下面的代码,但每次 运行 都会出现编译错误:找不到方法或数据成员。有谁知道为什么下面的代码不起作用?

Private Sub CommandButton1_Click()
Dim OL              As Object
Dim EmailItem       As Object
Dim Powerpoint      As Presentation

Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Powerpoint = ActivePresentation
Powerpoint.Save

With EmailItem
.Subject = "SUBJECT LINE"
.Body = "BODY MESSAGE" & vbCrLf & _
"SECOND LINE BODY MESSAGE" & vbCrLf & _
"THIRD LINE BODY MESSAGE"
.To = "NAME@COMPANY.COM"
.Importance = olImportanceNormal
.Attachments.Add Doc.FullName
.Send
 End With

Application.ScreenUpdating = True

 Set Doc = Nothing
 Set OL = Nothing
 Set EmailItem = Nothing
 End Sub

如有任何帮助,我们将不胜感激!

当演示文稿的新变量名称为 Powerpoint 时,您似乎仍在使用 Doc 变量。看看以下几行:

Doc.Save

.Attachments.Add Doc.FullName

Set Doc = Nothing

Doc 替换为 Powerpoint,您的代码应该可以正常工作。