从 PowerPoint 运行 Outlook 宏时出现错误 438

问题描述 投票:0回答:1

我正在尝试从 PowerPoint 运行 Outlook 中定义的公共宏。

我在调用 Outlook 宏的行上收到错误 438。

我在 PowerPoint 中的 VBA 代码;

Sub RunOutlookMacro()
    Dim OutlookApp As Object
    Dim OutlookNamespace As Object
  
    Set OutlookApp = GetObject(, "Outlook.application")
    Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")

    OutlookApp.Run "ThisOutlookSession.TestOutlook"       'TestOutlook is the macro in Outlook

    Set OutlookApp = Nothing

End Sub

在 Outlook 中调用的宏;

Public Function TestOutlook()
    msgbox "You have reached Microsoft Outlook"
End Sub
vba outlook powerpoint mapi
1个回答
0
投票

Outlook 的应用程序对象不支持 Run 方法。

Sub RunOutlookMacro()
Dim OutlookApp As Object
Dim OutlookNamespace As Object

Set OutlookApp = GetObject(, "Outlook.application")
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")

' Err 438 Object doesn't support this property or method
'OutlookApp.Run "ThisOutlookSession.TestOutlook" 'TestOutlook is the macro in Outlook

' Move all the code from "TestOutlook" into PowerPoint
MsgBox "You have reached Microsoft Outlook"

Set OutlookApp = Nothing
End Sub
© www.soinside.com 2019 - 2024. All rights reserved.