Outlook 2010 - VBA macro to execute a Ribbon Button
-
Tuesday, February 28, 2012 10:37 AM
Dear all.
I have a VBA macro that is executed in a rule once an email comes in. The macro sets the default printer to "Send to Onenote 2010" and prints the email on the printer. That works fine.
Now I would like to add functioanlity to the macro, that the incoming email is not printed to Onenote but moved to Onenote using the Ribbon Button "MoveToOneNote", which came with the OneNote Add-in. The beaut yin that is that the email is not transfered as a picture but as text and all the attachments are delivered to OneNote.
If bolOneNoteMsg Then
Item.GetInspector.CommandBars.ExecuteMso "MoveToOneNote"
End If
This code does not work unfortunately. It throws no error, but the email does not make it to OneNote either.
Can you please give me a hint, where to look for to resolve the issue?
Thanks
Stefan
All Replies
-
Tuesday, February 28, 2012 11:40 AMare you sure that this idMSO - MoveToOneNote is proper?
-
Tuesday, February 28, 2012 12:15 PM
I think so. I took it from the command list from the inspector ribbon command customizing.
While hovering over the command the following pops up:
Message tab | Move | OneNote (MoveToOneNote)
Any other combination failed in runtime error 5 invalid procedure call or argument.
Any other hint?
Thanks
-
Tuesday, February 28, 2012 12:42 PMIs inspector open when you call this? (is mail shown in its own window)
-
Tuesday, February 28, 2012 2:24 PM
Usually not.
Please be patient with me, I have only very very limited knowledge about the VBA and Outlook OM
-
Friday, March 02, 2012 7:34 AMModerator
Hi Stefan,
Thanks for posting in the MSDN Forum.
It's based on my experience that you need confirm the item's inspector is active when you do it.
Have a good day,
Tom
Tom Xu [MSFT]
MSDN Community Support | Feedback to us
-
Friday, March 02, 2012 2:39 PM
Hi Tom Xu
That was a good hint.
Just to get it somehow to work I tried this code:
Application.ActiveExplorer.CommandBars.ExecuteMso "MoveToOneNote"
And it really moves something to Onenote, but not the received item, only the currently marked email.
How can I get this to work with any received email?
Thanks and regards
Stefan
-
Friday, March 02, 2012 4:03 PM
Try to call Display on item, it should show up inspector for item. You could also try to fiddle with Explorer.AddToSelection/RemoveFromSelection.
-
Thursday, May 10, 2012 7:16 PM
Hi Stefan,
I've had the same idea as you. Any luck getting this macro to work?
- Rob
-
Thursday, May 10, 2012 7:56 PM
not yet, it is still on my list to do
the code itself works with the exception of my last post, so I guess it is only a small change left.
//Stefan

