后期绑定Outlook.Folder

时间:2018-02-27 14:28:59

标签: excel vba excel-vba outlook late-binding

使用两个不同的Office版本(2007和2016)时,我遇到了Microsoft Outlook对象库的问题。 我已经发现后期绑定是一个解决方案,但我不知道如何延迟绑定除Outlook.Application之外的其他对象。特别是" Outlook.Folder"和" Outlook.Selection"是我后期绑定所需要的。

我尝试创建对象就像我为我的Outlook.Application做的那样叫做" appoutlook"但是下面的代码一直给我一个错误信息,即无法通过ActiveX组件创建对象......

第一堂课:

Public Type Email_Attributes
 olApp As Object    
 olFolder As Object 
 olSelection As Object 
End Type

第二课:

Dim olMail As Object
Dim appoutlook As Object
Set appoutlook = CreateObject("Outlook.Application")
Const olMailItem As Long = 0
Set olMail = appoutlook.CreateItem(olMailItem)
Dim strAttName As String

Dim new_mail As Email_Attributes

Application.ScreenUpdating = False

Set new_mail.olApp = CreateObject("Outlook.Application")
Set new_mail.olFolder = CreateObject("Outlook.Folder")
Set new_mail.olSelection = CreateObject("Outlook.Selection")
Set new_mail.olFolder = GetObject("ActiveExplorer.CurrentFolder")
Set new_mail.olSelection = GetObject("ActiveExplorer.Selection")

非常感谢任何帮助!

0 个答案:

没有答案