Outlook对象库不会在版本12和14之间切换 [英] Outlook Object Library Does Not Switch Between Versions 12 And 14

查看:172
本文介绍了Outlook对象库不会在版本12和14之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网络共享上有一个.dotm模板文件.有一些宏,它们引用了Word,Office和Outlook对象库.我们使用Windows XP和Windows 7这两个不同的平台,以及Microsoft Office 2007和Office2010.当用户打开模板文件时,Word和Office的引用会自动调整,并因此进行相应的调整(即,它们被设置为Microsoft Word 12 Object库或Microsoft Word 14对象库(如果需要),宏运行就没有问题.

I have a .dotm template file on a network share. There are macros with references to the Word, Office, and Outlook object libraries. We use two different platforms, Windows XP and Windows 7, along with Microsoft Office 2007 and Office 2010. When users open the template file the references for Word and Office adjust automatic and accordingly (that is, they’re set to Microsoft Word 12 Object Library or Microsoft Word 14 Object Library as needed), and the macros run without a problem.

Microsoft Outlook对象库从版本12正确切换到14.它没有从版本14正确切换到12.在这种情况下,它给出错误消息:找不到该库.这是一个错误吗?有解决方法吗?我忽略了什么?

Microsoft Outlook Object Library switches properly from version 12 to 14. It does not switch properly from version 14 to 12. In that case, it gives the error that the libary is not found. Is this a bug? Is there a workaround? Something I’m overlooking?

推荐答案

ForEachLoop,

ForEachLoop,

您的问题似乎已经得到了解答.为了清楚起见,我将仅添加一些信息,并为该问题提供答案.微软论坛(Ossiemac)上的一位用户指出

It appears that your question has largely been answered. I will merely add a bit of information for clarity's sake, and to provide this question with an answer. A user on the Microsoft Forums, Ossiemac, noted that LateBinding was the way to go, as has been stated by Siddarth Rout. As implied by Siddarth, that means you do not have to worry about references.

Ossiemac提供了一些示例代码,用于在发送电子邮件中使用LateBinding,我将其重新格式化并放在此处:

Ossiemac provided some sample code for using the LateBinding in the sending of an email, which I have reformatted and placed here:

Private Sub btnLateBindMethod_Click()
    ' Variables used for LateBinding
    Dim objOutlook As Object    'Outlook.Application  
    Dim objEmail As Object      'Outlook.MailItem     
    Dim objNameSpace As Object  'Outlook.NameSpace    
    Const OutLookMailItem As Long = 0    'For Late Binding
    Const OutLookFolderInbox As Long = 6 'For Late Binding
    Const OutLookFormatHTML As Long = 2  'For Late Binding
    Dim strSubject As String
    Dim strAddress As String


On Error Resume Next
Set objOutlook = GetObject(, "Outlook.Application")
On Error GoTo 0     

    If objOutlook Is Nothing Then
        Set objOutlook = CreateObject("Outlook.Application")
        Set objNameSpace = objOutlook.GetNamespace("MAPI")
        objNameSpace.GetDefaultFolder(OutLookFolderInbox).Display
    End If

Set objEmail = objOutlook.CreateItem(OutLookMailItem)

strSubject = "Hello World"

    With objEmail

        '.To = strToAddress  'Commented to prevent accidental send

        .Subject = strSubject

        .BodyFormat = OutLookFormatHTML

        .Display

        'Full Name of window can change depending on Tools -> Options -> Mail Format
        'Changing this option for outgoing mail changes the window name.
        'However, AppActivate appears not to require entire name but needs up to end
        'of - Message which is included in heading following the Subject string
        'irrespective of the Mail Format option chosen.
        AppActivate (strSubject & " - Message")

    End With    
End Sub

Jimmy Pena的文章讨论了 EarlyBinding和LateBinding的对比-

Jimmy Pena has an article discussing the contrast of EarlyBinding and LateBinding -

〜JOL

这篇关于Outlook对象库不会在版本12和14之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆