简体   繁体   English

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

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

I want in PowerPoint: after a click on the command button, send e-mail with attachment (that same PowerPoint presentation) to specific e-mail address.我想要在 PowerPoint 中:单击命令按钮后,将带有附件的电子邮件(相同的 PowerPoint 演示文稿)发送到特定的电子邮件地址。

I used this based on internet, but I think that xDoc may be a problem?我使用这个基于互联网,但我认为 xDoc 可能是一个问题?

When I click on the button it says "user defined type not defined" and Private Sub CommandButton1_Click() is then yellow.当我单击按钮时,它显示“未定义用户定义类型”,然后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

That's a Word VBA statement.这是一个字 VBA 语句。 Try:尝试:

Dim xPres As Presentation

then change all the xDoc references in the code.然后更改代码中的所有 xDoc 引用。 ie: IE:

Set xPres = ActivePresentation

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

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