0
我試圖在Outlook 2010中使用某些VBA爲聯繫人列表引入圖片。當我上次在Outlook 2007中嘗試過這個功能時,它運行良好。但現在,我已升級到Outlook 2010,它不再有效。它將Dim rec上的錯誤記錄爲ADODB.record set行,並給出編譯錯誤:未定義用戶定義的類型。用戶定義類型未定義 - 使用VBA將圖片導入Outlook 2010中的聯繫人
任何想法我需要改變才能在Outlook 2010中工作?
Public Sub UpdateContactPhoto()
Dim myOlApp As Outlook.Application
Dim myNamespace As Outlook.Namespace
Dim myContacts As Outlook.Items
Dim myItems As Outlook.Items
Dim myItem As Object
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myContacts = myNamespace.Folders.Item("Mailbox - Thomas, Susan"). _
Folders.Item("Temp Contacts").Items
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
For Each myItem In myContacts
If (myItem.Class = olContact) Then
Dim myContact As Outlook.ContactItem
Set myContact = myItem
Dim strPhoto As String
Dim rec As ADODB.Recordset
Dim strSQL As String
strSQL = "SELECT abcdefg from 123456 Where FullName = '" & myItem & "'"
Set con = New ADODB.Connection
con.Open = "Provider=SQLOLEDB;Data Source=ABC;Initial Catalog=XYZ;User ID=867;Password=5309;"
Set rec = con.Execute(strSQL)
If Not rec.EOF Then
TheValue = rec.Fields(3).Value
strPhoto = "\\picserver\EmployeePics\" & TheValue
If fs.FileExists(strPhoto) Then
myContact.AddPicture strPhoto
myContact.Save
End If
End If
Else
End If
Next
End Sub
我看到現在在哪裏做的工具|引用,但是如何確定在我的機器上加載哪個版本?你的意思是我的機器上有什麼版本的Outlook? – Susan
ActiveX數據對象的版本 – SeanC
感謝您的幫助。我需要添加Active X.我之前一定是這樣做的,忘記了一切。 – Susan