In Outlook, composing a message, can I visually tag it somehow in VBA? - vba

I have a some VBA that will file an outgoing message as a Task (and do some other things) if I tag it. One way I tag is by calling a macro that sets a UserProperty; I have assigned the macro to a button on the command bar.
I would like to visually mark the message as having been tagged before I send it, and then implement a toggle, but I'm struggling to find a way of doing it. So keeping the button depressed, or highlighted, would work but I can't see how to do this in the Fluent UI stuff. Alternatively, I'd like to add something to the area to the right of the "pop out" "discard" buttons at the top of the message.
I tried adding a category to the new message, but this is not displayed in the pane. I do have a UserProperty assigned, but I don't know how to display that either.
Any ideas?
Many thanks

VBA doesn't allow customizing the Fluent UI. You need to develop a COM add-in instead. To implement a toggle button on the Ribbon you need to define callbacks where you may check the user property value and update the UI accordingly. The Fluent UI is described in-depth in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

Related

MS Word lock/unlock Quick Access Toolbar button with VBA

I have two buttons which I've added to the Quick Access Toolbar (QAT) in MS Word, both of which are linked to macros written in a module. I want the second button to be greyed out (or locked) until the first one has successfully run, at which point I will unlock in the code.
How do I access the button objects with vba? I'm looking for something along the lines of ActiveDocument.QATButton1.Locked = True. With a standard Active X button you can right click and view properties to get the button name but I can't seem to do this with these (they were created via Options>QAT>Macros>Add)
If you want to disable or enable your Fluent UI controls (QAT) dynamically you need to use ribbon callbacks with IRibbonUI.Invalidate or IRibbonUI.InvalidateControl methods. For each of the callbacks that the custom UI implements, the responses are cached.
For example, if an add-in writer implements the getEnabled callback procedure for a button, the function is called once, the state loads, and then if the state needs to be updated, the cached state is used instead of recalling the procedure. This process remains in place until the add-in signals that the cached values are invalid by using the Invalidate method, at which time, the callback procedure is again called and the return response is cached. The add-in can then force an immediate update of the UI by calling the Refresh method.
You may find the Ribbon UI (aka Fluent UI) described in depth in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

How to create toggle button for Macro

I have created a macro that will set the categories of out going mail without needing to open the tag dialog. I have added the macro to the ribbon via the "Customize Ribbon" options on outlook itself. That macro works fine, however I would like the button to be highlighted (toggled on) when the category is set and then regular (toggle off) when the category is no longer set.
I only have basic VB knowledge but have good knowledge of java so the concepts are familiar just not the syntax. This is also the first macro I've ever done.
I have tried searching Google and Stack for an answer but I think due to my lack of knowledge I'm not using the correct keyword to get a useful result.
Thanks for the help.
VBA macros don't allow creating a custom ribbon UI. You need to develop a COM add-in if you want to customize the Fluent UI by adding a toggle button to the Outlook window.
Take a look at the following articles to create a custom ribbon UI:
Walkthrough: Create a custom tab by using the Ribbon Designer
Walkthrough: Create a custom tab by using Ribbon XML
The Fluent UI is described in depth in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

PowerPoint 2010 - VBA - Use Ribbon Button Inside of a Userform

Is it possible to take a pre-existing button from the ribbon, Shape Fill from the Shape Styles category for example, and display it in a VBA userform?
My add-in manages a large number of shapes, and I would like to allow the user to style those shapes based on the category that they are in in the add-in.
I have read that a color dialog does not exist for us to use in VBA, so I'm trying to think of a way to work around that. Recreating all of the fill, outline, and effects menus seems like too much, there has to be a better way.
No, built-in ribbon controls can be used on the ribbon only. As a workaround you may consider using any ActiveX custom controls on your form.
Also you may consider creating a custom UI on the ribbon. In that case you will be able to add built-in ribbon controls to your own tab by specifying its idMso value. The full list of control IDs can be found in the following documents:
Office 2010 Help Files: Office Fluent User Interface Control Identifiers
Office 2013 Help Files: Office Fluent User Interface Control Identifiers
Office 2016 Help Files: Office Fluent User Interface Control Identifiers
Read more about the Fluent UI (aka Ribbon UI) in the following series of articles:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

How to make changes in Ribbon elements of a single excel instance, using application-level add-in?

I'm using VSTO with VB.NET for Excel 2013. I'm developing an application-level add-in, but I can't make two different workbooks store different "ribbon state". For example, when I want to enable a button, I use the following code:
Globals.Ribbons.Ribbon1.myButton.Enable = False
This makes the element "myButton" to be disabled on each opened workbook, but I want to make it disabled only for one workbook.
The way I'm doing now is to handle the event WorkbookActivate, to change the ribbon state. The problem is: this way, the user sees an invalid state at other workbooks that are not on the top.
There is some better workaround? There isn't a way to manage the ribbon instances (and not only the global element as I am doing)?
Thanks
There is some better workaround? There isn't a way to manage the ribbon instances (and not only the global element as I am doing)?
You need to use callbacks instead. Try to use the getEnabled callback instead.
Moreover, when required you can use the IRibbonUI interface methods to force Office applications to update the UI controls. The Invalidate method invalidates the cached values for all of the controls of the Ribbon user interface. See Overview of the IRibbonUI Object .
You can read more about the Ribbon UI (aka Fluent UI) in the following series of articles in MSDN:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)

Outlook create a button like 'Private'

I want to create a button like the 'Private' button when creating a new appointment/meeting. So that the button freeze in the mouse hover style when it gets clicked.
I create the button in the VBA project like this:
Set objCBC = objCB.Controls.Add(Type:= --WHICHTYPE--, _
Temporary:=True)
So does anybody know which type of button should be applied here??
Command bars were deprecated. You need to use the Fluent UI (aka Ribbon UI) instead. Unfortunately Outlook doesn't allows to customize the Fluent UI with VBA, you need to develop an add-in instead. You can read more about the new UI in the following series of articles in MSDN:
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
See the toggleButton control in the list of available controls.