问题
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