我正在尝试编写一个outlook宏,它将在所有Contacts上创建一个新字段,然后根据另一个已存在的字段填充该字段。这是我到目前为止所拥有的。它似乎没有创造任何东西。
Sub ChangeField()
Dim ContactsFolder As Folder
Dim Contact As ContactItem
Dim objProperty As UserDefinedProperty
Set ContactsFolder = Session.GetDefaultFolder(olFolderContacts)
MsgBox ("Contacts Found: " & ContactsFolder.Items.Count)
With ContactsFolder.UserDefinedProperties
Set objProperty = .Add("CustomCompanyField", olText)
End With
For Each Contact In ContactsFolder.Items
Contact.CustomCompanyField = Contact.CompanyName
Contact.Save
Next
End Sub
可以通过VBA完成吗?或者只能手动创建联系字段?任何帮助表示赞赏!
答案 0 :(得分:0)
尝试替换
行 Contact.CustomCompanyField = Contact.CompanyName
与
Contact.UserProperties.Add("CustomCompanyField", olText).Value = Contact.CompanyName