Applescript 使用 Microsoft Outlook 联系人填充对话框列表

发布于 2024-11-04 05:36:53 字数 224 浏览 0 评论 0原文

总之,

我正在尝试创建一个applescript,它允许我创建一个word文档(商业提案)。其中之一是能够使用 applescript 从 Microsoft Outlook 中选择客户端。

我知道如何在 VBA 中执行此操作,但在 Applescript 中我似乎无法弄清楚。基本上,我需要一个对话框,其中包含所有 Outlook 联系人的列表,我可以从中选择一个。

非常感谢, -J

All,

I'm attempting to create an applescript that allows me to create a word document (a business proposal). One part is being able to use applescript to select the client from micorsoft outlook.

I know how to do this in VBA but in Applescript I can't seem to figure it out. Basically I need a dialog box that either has a list of all my Outlook contacts from which I can select one.

Much appreciated,
-J

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼泪都笑了 2024-11-11 05:36:53

又快又脏,但是可行(Office 2008) 该

tell application "Microsoft Entourage"

    set contactList to {}
    set lastContact to (count contacts)
    repeat with thisContact from 1 to lastContact
        set theContact to item thisContact of contacts
        set end of contactList to (first name of theContact & " " & last name of theContact)
    end repeat

    set contactSelected to (choose from list contactList with prompt "Please select a contact." without multiple selections allowed) as text

    if (contactSelected is not "False") then
        display dialog contactSelected
    end if

end tell

脚本本质上有两个部分:获取联系人姓名和显示信息。获取联系人很容易,因为 contacts 是应用程序本身的属性。在 40 多个联系人中运行此操作只需一秒钟。

呈现数据并进行选择并不是那么明显。要呈现的数据必须是一个字符串。老实说,我忘记了为什么我有 as text 悬在末尾,但我似乎记得,如果所有内容都作为某种字符串处理,那么这样做会更容易。一旦验证了选择(返回“False”意味着用户单击了取消按钮),您就可以继续使用我放置显示对话框的字符串。不幸的是,您没有得到行号或类似的方便信息。它只是无法以这种方式工作,因此您必须做一些捏造才能返回到相应的 contact 对象本身。

加盐调味...

Quick and dirty, but this works (Office 2008)

tell application "Microsoft Entourage"

    set contactList to {}
    set lastContact to (count contacts)
    repeat with thisContact from 1 to lastContact
        set theContact to item thisContact of contacts
        set end of contactList to (first name of theContact & " " & last name of theContact)
    end repeat

    set contactSelected to (choose from list contactList with prompt "Please select a contact." without multiple selections allowed) as text

    if (contactSelected is not "False") then
        display dialog contactSelected
    end if

end tell

There are essentially two parts to the script: getting the contact names and presenting the information. Getting the contacts is easy because contacts is a property of the application itself. Running this in 40+ contacts only takes a second.

Presenting the data and getting the selection isn't so obvious. The data to be presented has to be a string. Honestly, I forget why I have as text dangling off the end, but I seem to remember that doing this was easier if everything was handled as a string of some kind. Once the selection has been verified—having "False" returned means the user clicked the cancel button—you are then able to carry on with the string where I placed the display dialog. Unfortunately, you don't get the row number or anything convenient like that. It just doesn't work that way, so you will have to do a bit of fudging to get back to the corresponding contact object itself.

Add salt to taste...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文