Call Word Menu-Button in VBA? - vba

everyone,
I am new to VBA and would like to know if it is possible to execute a menu button from a WordAddIn.
In the picture you can see which button I would like to execute using VBA.
Unfortunately, I can't record it via macro.

The Word object model allows executing built-in ribbon controls using the CommandBars.ExecuteMso method which executes the control identified by the idMso parameter. This method is useful in cases where there is no object model for a particular command. Works on controls that are built-in buttons, toggleButtons, and splitButtons.
But in your case the control comes from a third-party add-in which doesn't expose IDs and the CommandBars.ExecuteMso method can't find it and invoke the command programmatically.
To get the job done you may consider using the Microsoft Active Accessibility which is a Component Object Model (COM)-based technology that improves the way accessibility aids work with applications running on Microsoft Windows. It provides dynamic-link libraries that are incorporated into the operating system as well as a COM interface and API elements that provide reliable methods for exposing information about UI elements.
Also you may contact the add-in vendor for providing public methods that can be called from your solution. That's also a possible workaround instead of calling UI elements on the ribbon.

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.

undo for non textbox controls

new to .net coming from vba decided to rewrite a management app using vb.net and SQL Server.
Started writing the base library for my application.
I created custom controls to use in my application that would expose a Zoom function, background color for the current active control a .modified property similar to the one available in textbox and some extra other properties (SQLTableName, SQLColumnName, ...) to enable iterating through a container (form) for modified controls and Update/Insert into a SQL table via a SQLProcessClass.
Concurrently I'd like to also implement a simple undo functionality.
My first idea was to add a PrevValue variable set in the OnEnter event if the Modified property is False, exposing an OldValue property and an Undo method in the custom controls.
However I found that the TextBoxBaseClass already exposes an Undo method and that there is an UndoEngineClass available.
Unfortunately the vs helpfile does not give examples of how to use / implement that class.
Could someone explain the usage of the UndoEngine class non-textbox controls and if it is advisable to use it or rather write my own (as I first intended to do - I also found some interesting articles about undo/redo classes) but why reinvent the wheel in case .net already provides a class for it.
thks

VSTO XML ribbon - is there a single instance of the ribbon?

I'm trying to understand some of the behaviors I'm experiencing in my custom outlook VSTO ribbon and the main difficulties I'm facing are tied to what seems to be a single instance of the ribbon being shared among concurrently open inspector windows (my custom ribbon is displayed for ribbon type "Microsoft.Outlook.Mail.Compose"). Is there indeed a single instance of the ribbon being shared among potentially multiple instances of inspect windows? If so, how do you handle concurrent different states in the different inspector windows?
What you do is create the one custom Ribbon and from each view you handle the items in the Ribbon that you need. Here is a question that somewhat relates to your question:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/57dc20bb-9d29-4d3e-84d2-c64de0af0244/iribbonextensibilitygetcustomui?forum=vsto
In your case you want to maintain state, that is using the same paradigm. Whenever you get focus on the composing mail you make sure the state of the Ribbon matches the state of the composing mail.
By doing so the one time loading of the Ribbon XML is no longer an issue as you have all items in one Ribbon and are able to manipulate the state for each of the composed mails.

How to show a waiting dialog, in the meantime, still keep dealing with PowerPoint objects?

I want to show a waiting dialog, in the meantime all the calculations concerning with PowerPoint objects still are running in the background. My purpose is during the time dealing with PowerPoint objects, I try to prevent the user from interfering with the UI.
It seems that there is no way to deal with PowerPoint objects in the background. Is there any workaround for my case?
Thanks
Note: I am using VS Ultimate 2013, C#, PowerPoint 2013, vsto
Office applications use the single threaded apartment model. That's why you need to use the main thread for working with Office/PowerPoint objects. However, you can extract the required information into .Net collections and process the data on another thread.
But if you need to work with PowerPoint objects, a possible solution is to display a non-dialog form with a progress bar which display the state of your actions. Thus, end users will not be able to access the UI of PowerPoint. Don't forget to specify the parent window handle (PowerPoint window handle) for the Show method (see the IWin32Window interface).

How to identify a specific ActiveX Interface based on limited information

I am in the process of developing an ActiveX control for embedding in Rockwell Automation's Factory Talk View. (See ActiveX DLL Error: Solved to see how great a start I got off to!)
At the moment I have an ActiveX control that seems to embed into the host system OK, but is not fully integrated into the VBA process. I believe that this is because I have not implemented some specific COM interface that is required, but I have no documentation as to what that is. I do know that standard MS controls like the Microsoft Forms 2.0 controls do implement the required interface and fully integrate.
The key functionality I am missing relates to a property that I need to set in order for my VBA code to actually see the ActiveX object. This property can be seen when opening the property panel for any activeX control placed on a Factory Talk screen, but NOT when looking at the properties of ActiveX controls embedded in (for example) Excel. Thus I am probably trying to chase down some custom Rockwell implementation. I am hoping that SO might be able to give me some aid into how to track down what I want based on recognizing the functionality it implements.
Now to the actual property. In Factory Talk the property is called "ExposeToVBA", and has a type "long". You have a choice of 3 values selected from a drop down list:
Not Exposed - When set to this, the controls name is not even visible to VBA code
Type Info Extension - Not sure what this does
VBA Control - VBA code can see and interact with the control.
When I select anything other than "Not Exposed" for my control, I get a warning dialog box with no text on it. For other controls I need to set it to "VBA Control" in order to interact with it in the VBA code (d'oh)
I suspect that the value of this property is translated into some calls to an ActiveX interface on the target control.
The Question
What I want to do is identify what interfaces something like a "Forms 2.0 Label" implements that would match the above functionality. And also perhaps how I could translate this into my C# based control (based on C# ActiveX control (CSActiveX))
I know its a long shot, but I'd appreciate any and all suggestions
This became moot when I found a canned Active-x control that had the functionality that I needed.
FWIW This is what I believe that I used: DMGraph