我正在尝试从 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
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