繁体   English   中英

对声明为 Document 的 xDoc 的引用在 PowerPoint VBA 中生成“未定义的用户定义类型”

[英]Reference to xDoc, declared as Document, generates “user defined type not defined” in PowerPoint VBA

我想要在 PowerPoint 中:单击命令按钮后,将带有附件的电子邮件(相同的 PowerPoint 演示文稿)发送到特定的电子邮件地址。

我使用这个基于互联网,但我认为 xDoc 可能是一个问题?

当我单击按钮时,它显示“未定义用户定义类型”,然后Private Sub CommandButton1_Click()为黄色。

Private Sub CommandButton1_Click()
    Dim xOutlookObj As Object
    Dim xEmail As Object
    Dim xDoc As Document
    Application.ScreenUpdating = False
    Set xOutlookObj = CreateObject("Outlook.Application")
    Set xEmail = xOutlookObj.CreateItem(olMailItem)
    Set xDoc = ActiveDocument
    xDoc.Save
    With xEmail
        .Subject = "Lorem ipsum"
        .Body = "Lorem ipsum"
        .To = "xyz@xyz.xyz"
        .Importance = olImportanceNormal
        .Attachments.Add xDoc.FullName
        .Display
    End With
    Set xDoc = Nothing
    Set xEmail = Nothing
    Set xOutlookObj = Nothing
    Application.ScreenUpdating = True
End Sub
Dim xDoc As Document

这是一个字 VBA 语句。 尝试:

Dim xPres As Presentation

然后更改代码中的所有 xDoc 引用。 IE:

Set xPres = ActivePresentation

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM