【发布时间】:2013-10-04 15:06:50
【问题描述】:
当总机加载时,我正在尝试从 Access VBA 打开 Outlook 应用程序。我打开了任务管理器,我可以看到一个 Outlook 实例出现大约 5 秒钟然后关闭,但我无法打开资源管理器窗口。我一直在尝试拼凑来自VBA: Determining whether an existing Outlook instance is open 和其他来源的代码,但它只是不起作用。有什么想法吗?
而且我想坚持使用后期绑定,这样我就不必担心如果有人用 XP 打开对象库。
Function OpenEmail()
Dim olApp As Object ' Outlook.Application
Dim olFolderInbox As Object
Dim objExplorer As Object
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If olApp Is Nothing Then
MsgBox "Outlook is not Open"
Set olApp = CreateObject("Outlook.Application")
End If
Set objExplorer = CreateObject("Outlook.MAPIFolder")
Set objExplorer = olApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
objExplorer.Activate
'Set olApp = Nothing
End Function
【问题讨论】: