How to programmatically open an Outlook Shortcut

限于喜欢 提交于 2019-12-02 13:19:50

问题


I'm wondering if there is a way of programmatically opening an Outlook Shortcut from my addin.

I've created the shortcut as follows

Sub AddShortcut()
    Dim myOlBar As Outlook.OutlookBarPane
    Dim myolGroup As Outlook.OutlookBarGroup
    Dim myOlShortcuts As Outlook.OutlookBarShortcuts

    myOlBar = Application.ActiveExplorer.panes.Item("OutlookBar")
    myolGroup = myOlBar.Contents.Groups.Item(1)
    myOlShortcuts = myolGroup.Shortcuts
    myOlShortcuts.Add("http://microsoft.com/", _
    "MSHomepage", 1)
End Sub

I'm guessing I need to use InvokeMember in some way

myOlShortcuts("MSHomepage").GetType().InvokeMember(..) 

But when I use GetType().GetMethods() I can't see any Click members or something similar. Any help is very much appreciated.


回答1:


If you want to trigger the Outlook integrated web browser, you should grab the OutlookBarShortcut.Target. If the Target is of type string, then use the following (substituting your Target for the address Text)...

Office.CommandBarComboBox address = (Office.CommandBarComboBox)Application.ActiveExplorer().CommandBars.FindControl(26, 1740);
address.Text = "http://www.stackoverflow.com";

otherwise the type is Folder and you should assign Explorer.CurrentFolder. The only downside with this approach is that CommandBars have been deprecated with Outlook 2010 and this solution likely won't work in the next version of Office.

Another alternative is to use Web Folder behavior as discussed in this SO post. You could create a hidden Folder used just for the purposes of navigation.



来源:https://stackoverflow.com/questions/10996394/how-to-programmatically-open-an-outlook-shortcut

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!