How does one go about handling events that cannot be accessed from the ribbon visual designer in visual studio?
For example I would like to handle a mouse movement into the activesheet or if a user switches between worksheets. How do I go about subscribing to that event? Is there any way to generate an event handler for these kinds of events (that don't involve controls in the ribbon) automatically in visual studio.
Ive spent quite a few hours trying to figure this out (I am new to VSTO and c#) with no luck.
Thanks a lot
Many excel objects expose events. Look into Worksheet and Workbook events for example:
http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.worksheet_events.aspx
http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.workbook_events.aspx
Related
I have a macro that extracts data from Microfocus RUMBA Mainframe Display and puts in Excel rows one after the other. I have created a Global Mainframe object and that is used for extraction to Excel. But when the process is running and if user decides to stop the processing he cannot click on Stop button on Excel or go to different tabs to see the data being pasted. He has to clicks like 6 times before tabs are switched or stopped.
I see that DoEvents allows mouse click events in the loop to do things but the code is written in a way that there is a lot of lines with in the loop and a function with no loop, and placing DoEvents after everyline seems irrational. I have a feeling there is a better to do that but not sure what that is. Can anyone please help?.
VBA is single threaded. So you can't have one VBA action interrupt another. If you had a cancel button, for example, and the user was allowed to click it via a DoEvents processing the cancel action would still run after the currently running procedure.
In Excel this single threaded nature ends up being a good thing because you generally don't want the user interacting with the workbook while you are making programmatic changes. If this was allowed you would get undefined behavior.
Your best course of action would be to make a .NET application that uses the Excel Interop extensions to move the data from the mainframe to Excel. If you use VB.NET then you will find the code is quite similar to VBA. In fact, the Excel.Application object model is identical so the macro code you already have ports cleanly over.
There is an add-in that will help RUMBA development here:
https://www.microfocus.com/documentation/rumba/desktop951/RumbaSystemAdminGuide/GUID-DDB7571D-6167-4F8B-876E-E7450F3030B2.html
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
I'm on the VBA ---> VB .NET journey and am in the process of building a custom Excel ribbon for Excel 2013/16 in Visual Studio.
When I selected the ribbon as the project, Visual Studio added a few tabs, one of which houses the code for the on-click actions for the buttons.
My background being VBA, I'm used to being able to have separate modules for different things and want to do the same (e.g. one module for calculation buttons, one module for formatting buttons, etc.) but can't see a way to have separate modules in this fashion. I tried to just create a new tab in VS but got nowhere with that...
Any ideas?
Try Project>Add new Module
by this way you can create separate module for all different calculation.
you can call this module procedure from button click event of ribbon code.
Since you are now using VS Studoi for Excel Plugin (VSTO) development, I don't think here you will find different modules for differet functions/onclick/events.
But as an alternate you can crearte partial classes here and can break your code in different files. In vb.net it will add new functions and event code in the single file only by default
I'm creating a native C++ Outlook add-in (.dll) and started my Visual Studio 2013 project using MS guidance. The idea is to get user input from a dialog box when the user clicks a Ribbon button and then act on the input after the dialog closes.
Where I need help is creating a Window in the ButtonClicked function. I've tried all the wrong ways which include MFC class wizard and ATL window (CAxDialogImpl). The common denominator is I don't have a valid parent window to create another window. Even if I get an active window handle from outlook.
Ideally, I wouldn't take a dependency on MFC but will use it if necessary. I'm looking for assistance creating a dialog/window, any ideas on how to achieve this?
I get C#/managed is the way to go, but the requirements dictate otherwise.
QI the Application.ActiveWindow property (it will be either Explorer or Inspector object) for IOleWindow and call IOleWindow::GetWindow().
I know Visual Studio has a Command system for creating custom keyboard shortcuts. Is there anything similar for Excel?
Is there a way to access the collection(s) of possible 'actions', including those that can be triggered by keyboard shortcuts or menu items? And if so, are there any events for detecting them?
The purpose of the add-in is to track excel feature usage, preferably including activation time and context, and whether or not the user activated it via keyboard or a menu.