【问题标题】:Contact FileAs name联系人文件名称
【发布时间】:2019-12-26 14:10:24
【问题描述】:

我使用以下文档来修复现有联系人的 FileAs 条目。它不适用于公司名称的联系人。

https://docs.microsoft.com/en-us/office/vba/outlook/concepts/address-book/programmatically-change-the-display-format-for-all-contacts

由于 Firstname 和 Lastname 字段为空白,因此 FileAs 条目为空白(" "+" "+" ")。

如何查找空白 FileAs 字段并将 CompanyName 字段设置为 FileAs 字段?

【问题讨论】:

  • 一个if 语句,检查名字和姓氏是否为" ",如果是companyname
  • 感谢您的及时回复。显然我无法按 Enter 键跳过这些 cmets 中的一行?
  • '过滤消息类以仅获取文件夹中的联系人项目 Set contactItems = items.Restrict("[MessageClass]='IPM.Contact'") For Each itemContact In contactItems If itemContact.FileAs = "" OR " " 然后 itemContact.FileAs=itemContact.Company itemContact.Save Next
  • 我的问题更多是关于细节和语法,我不是程序员。我编写了上面的代码来尝试实现这一点,但它告诉我“运行时错误'13':类型不匹配”。

标签: vba outlook contacts


【解决方案1】:

应该是这样的:

Set contactItems = items.Restrict("[MessageClass]='IPM.Contact'")
For Each itemContact In contactItems
'The underscore on the line below breaks the line into two lines.
'You need the left side of the equals for each condition in the if cant do or " "
    If itemContact.Firstname = "" Or itemContact.Firstname = " " _
    Or itemContact.lastname = "" or itemContact.lastname = " " Then
        itemContact.FileAs = itemContact.Company
        itemContact.Save
    end if
Next

【讨论】:

  • 再次感谢您的帮助。非常感谢。
猜你喜欢
  • 2011-05-19
  • 2013-07-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-01-25
  • 1970-01-01
相关资源
最近更新 更多