How to hook a Window Form within Microsft Excel from VBA? - excel

I'm trying to hook a Window Form within Microsoft Excel itself like on the attached picture (This is an Addin called Kutools).
It is supposed to:
Fit on the right side of the Row number
Be Just below the name box
Be resizable and the window is resizable with it as well
Be collapsible or Expandable (like on the image)
I prefer to use the internal VBA of Excel to build and hook it as much as possible. But if I have to use an external Editor (Visual Studio C# or VB. Net ...) I'm willing to follow the instruction.
I searched all over the web but couldn't find a way to do this. I definitely appreciate your kind assistance on this.
Thanks for your help, I'm open to any suggestion!

If I am not mistaken, you are trying to create a custom task pane for Excel (add-in). If so, then this link might help you, but you need to build it with Visual studio using Office development tools:
https://learn.microsoft.com/en-us/visualstudio/vsto/custom-task-panes?view=vs-2019

Related

Custom Pane In Excel

I am trying to create a custom static pane on the right side. so it shall be independent of zoom and scroll function in excel. please see the image for more. I tried the following. but no success.
I not sure whether the split-screen function in excel can help to achieve this.
Please note: I want to do it in page layout mode. as I was to set cell sizes in inch.
I tried the following.
ActiveSheet.Range("H1").Select
ActiveWindow.FreezePanes = True
ActiveSheet.Range("H1").zoom = False
I have no idea to make it work, as I am new to VBA. I need a user interface something like in the picture below. so I can scroll on the left but static part on right. in the static part, I would be able to add custom controls like Combobox, command button, TextBox, etc. Thanks
You have 2 solutions:
VSTO Taskpane add-in:
Custom task panes give you a way to create your own task pane and provide users with a familiar interface to access your solution's features. Custom task panes let you integrate your features into a familiar user interface. You can create a custom task pane quickly by using Visual Studio tools.
Document: https://learn.microsoft.com/en-us/visualstudio/vsto/custom-task-panes?redirectedfrom=MSDN&view=vs-2019
Office JS Taskpane add-in:
You can create an Office Add-in by using the Yeoman generator for Office Add-ins or Visual Studio. The Yeoman generator creates a Node.js project that can be managed with Visual Studio Code or any other editor, whereas Visual Studio creates a Visual Studio solution. Select the tab for the one you'd like to use and then follow the instructions to create your add-in and test it locally.
Document: https://learn.microsoft.com/en-us/office/dev/add-ins/quickstarts/excel-quickstart-jquery?tabs=yeomangenerator

C# VSTO Add-in Excel: What is the name of this Excel Super-Tab Control and how to make it? (Contextual Tab or Tool Tab)

In Excel (On Windows), there is a kind of a Super-Tab appearing on top of certain Tabs:
«Drawing Tools» Super-Tab:
When you click on a Graphic object then, this one appears:
«Table Tools» Super-Tab:
When you click inside of a Table object then this kind of a Super-Tab appears:
So my Questions are:
What is the technical name of that Super-Tab?
---> Special thanks to #TimWilliam. He was the one who gave its name: It is a Contextual Tab Set
And how to program something like that in VSTO Add-in please? (Anything related to it)
Your responses are much appreciated!
I'm answering to my Question so I do not lose all the important answers and research I got till now:
1. The name of that kind of Super-Tab:
The credit goes to #TimWilliams. The name of that Special tab is Contextual Tab or also called Tool Tab.
Here it is an official Information from Microsoft entitled: Ribbons
2. How to program the Contextual Tab?
I am still looking for How to program this one. At least Microsoft already explains about it here >>> 2.2.41 tabSet (Contextual Tab Set)
I found 2 new interesting discussions and information over here Adding custom contextual tabs to Ribbon UI and over here Ribbon: Contextual tab on application page. But they are all for ASP.NET.
Here as well is the List of Tool Tab available on Excel: Tool Tab Available on Excel
But once I found a working solution, I will share here as well for the advancement of our work.
Keep it up dear Programmers and stay blessed!
#TsiriniainaRakotonirina

How to customize the Excel Function Wizard?

I would like to customize the Excel Function Wizard, for instance by adding some buttons to the window and/or by firing a new event when the user press the OK Button.
I know that It is possible because the Bloomberg Excel Add-in implemented it.
I found no information about it on the web. I guess that I have to intercept calls to the Windows API and to play with the handle of this window to achieve this but I'm not sure. I see no way to do it via the Excel COM API or the Excel C API but I may be wrong.
Does anyone know how to do this ?
ps: I'm taking about the following window :
EDIT
See below a screenshot of the Bloomberg Wizard with a hyperlink for the optional argument that open a new window (not natively supported by the Excel C API)

Lock Drawing Mode VSTO 4.0

i am working on an Excel AddIn Development using Visual Studio Tools for Office (VSTO 4.0).
there is an option in Excel Lock Drawing mode for specific shape which enable a user to draw a shape multiple times.
my requirement is to enable "Lock Drawing mode" (for ElbowConnector) using C#/VB.Net using VSTO 4.0.
i tried to find a solution to this even in VBA but did not get any luck.
Thank you,
Regards,
You can try to execute the built-in button programmatically. The ExecuteMso method of the CommandBars class allows to run the built-in controls programmatically. See Office 2013 Help Files: Office Fluent User Interface Control Identifiers.

How to detect what Ribbon is currently active in a Microsoft Office application?

I have looked at ActiveControlList but unfortunately it wasn't a reliable way to tell the active ribbon.
Specifically, I am looking for a reliable way to tell if Equation Tools ribbon is active in OneNote.
Do you have any suggestions ?
The ribbon is not a normal control and can be hard to work with from plain VBA or ahks built-in COM but you can use Microsoft's Active Accessibility API
You Can use the Acc lib so you don't need to know all the dll calls
But you still need to know what parts you need, and also what to look for to really use it. You can use jethrows AccViewer it will tell you the elements Role, State, ChildCount and more, so when you have found the item you're after, you can use the Tree or path that the accViewer gives.
Word ribbon path Example: 4.3.4.1.4.1.4.1.4.1.4.13.1.1
OneNote: 4.3.4.1.4.1.4.1.4.1.4.10.1.1
Here is an example using Acc_get() to show the current ribbon Name in OneNote PP 2010 when you press F6
f6::
name := Acc_Get("Name", "4.3.4.1.4.1.4.1.4.1.4.10.1.1", 0, "Ahk_class Framework::CFrame")
tooltip % name
return
Note: that this path is for when the ribbon is pinned i.e always visible
Forum topic with images
As far as I know there are no specific commands for Ribbon GUIs.
Use ImageSearch to detect changes in Ribbon GUI. You can search with ImageSearch image of activated Equation Tools control and if it finds it, it will set ErrorLevel to 1.
Also, always use AutoHotkey and its documenatation from http://ahkscript.org/ (current uptodate version, new official website)! AutoHotkey and its documentation from autohotkey.com is outdated and you may have some problems using them!

Resources