簡體   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