Read values from the Office 2007 ribbon using VBA - vba

Using VBA, can I find out the value of a text (combobox) control on the Word 2007 ribbon?
Say I'd want to read the currently selected font name in the "Home" tab.
I've seen an example using the IAccessible interface to do some interaction with the Ribbon (namely enumerating it), but it seems reading a control value is not possible. Is there another way to do it, or is VBA locked out completely?

I don't think you can get at the ribbon to read the built in properties.
For you specific example of Font name you can use the following.
Msgbox Application.Commandbars.Findcontrol(ID:=1728).Text
You maybe able to adpat the approach for other information.

Related

VSTO Addin - Own button type like "ShapeWidth" and "ShapeHeight"

I am currently working on an PowerPoint Addin and I am currently finishing the Ribbon. I'd like to create a control to change the size of objects that looks similar to the inbuild button "ShapeWidth" and "ShapeHeight":
However, I couldn't find the correct control type and hence I built the below by myself using an editbox and buttons. Although it's working I find the other style way cleaner but I haven't found the correct type.
Not all Ribbon X (Office Fluent UI) control types that Microsoft uses in its Office applications are made available to third-party developers. This, I'm afraid, falls into that category.
You should probably be able to get the image, at least, by specifying the idMso for the built-in control.

How to put a button into Quick Access Toolbar in MS Word 2010 with a macro (VBA)?

I import bsa file as module. And macro run properly. I need to set up these macros buttons in to Quick Access Toolbar (QAT). I do it manually from standart way as well. But i want to make this automatically with macro (VBA). How these macros assigned to the buttons and buttons set up on the QAT by VBA inside macro?
I searched a lot, and the only way I was able to find was using Office Fluent User Interface.
See this article that walks you through doing it. The example is Excel's QAT, but since all Office Products share the same Type Library, you should be able to adapt it for MS Word 2010.

Excel VBA: How to turn code into a full on toolbar tool? [duplicate]

I am in the process of creating a VBA add-in for Excel 2010, and I used the "Custom UI Editor for Microsoft Office" tool to create my own ribbon.
However, I would like to give the user the option to load my add-in without displaying the ribbon, or with different parts of the ribbon visible.
With menus, I know you can completely control them programmatically, but ribbons seem to work differently.
Is there a way in VBA to not load my customUI.xml ribbon tabs on startup?
Is there a way to remove items from (or add items to) these tabs at runtime?
here is a whole slew of help on this subject Awesome Ribbon Help. I think points 2 and 3 are of particular interest to you.

Please let me know feasibility using Excel and VBA programming and suggest solution approach

We have following requirement to be done via excel and VBA programming. Please check and let me know if it feasible to do so and if not what way would be best to do it.
There would be excel spreadsheet say excel 2007/2010 with 2 tabs.
1st tab contains normal excel data
In 2nd tab user can enter a particular value and then click on a button in same tab. Is it possibly to have a button in excel tab and can it raise events like windows/web applications?
Now if button can be kept in excel and it can raise button click event then on such an event we need to create xml files. Is it possible to create xml files adhering to schema using excel &/or VBA programming
You need to activate the developer tab (from backstage go to Options and check the visibility of this tab) to get access to normal windows controls, like buttons and drop-down lists etc. You can easily place those in Excel sheets and write event handlers: the controls support the full range of events, including OnClick, OnMouseEnter etc...
You can write custom text files directly from VBA, but you can't validate those. The usual way to do so is just to concatenate small XML blocks into a bigger file, so XML output is more like a normal text output. But it works fine and as long as you do not need to perform something really complicated it is also ok.
EDIT: You can easily add references to custom COM objects (.dll or .ocx) and use them directly in your VBA code. One very helpful suggestion (see the comment below) is to use the MS XML library.
To add a reference just open the code editor (Alt + F11) and then go to Options -> References. Most of the references you need will be already in the list and you just have to check them, but you can also add your own custom libraries by clicking on Browse.

Powerpoint 2007 - Inserting dynamic data

so I've found that Powerpoint 2007 has no bookmark functionality. So I can't just insert dynamic data into a presentation. Also, there are no autostart event handler, but I found a way of doing it by editing the XML data. This now works, I've got a custom event handler that is run as expected.
Now, I tried to solve the no bookmark functionality by adding a label insted. Since a label has a name I can assign the Caption property a value. And that value can be dynamic data.
And this actually works, yay! BUT, this presentation has a custom font and font embedding is crucial. And now I've found that PowerPoint 2007 doesn't look to support font embedding on labels. And probably not buttons and textboxes as well. That is, the typical visual studio controls.
Are there any other ways of fixing this? A normal text placeholder doesn't have an ID.
But can I target them anyway? It's just some text in the footer of a slide design that I'm trying to put dynamic data.
Ok, so I found out how to target textboxes in PowerPoint 2007.
ActivePresentation.SlideMaster.CustomLayouts.Item(11).Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Select
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1, Length:=25).Select
ActiveWindow.Selection.TextRange.Text = "New text that should be inserted"
The problem now is how to run this automatically. New thread for that.