VSTO Excel ribbon tab - separate code (.NET) into modules - excel

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

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

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

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

How to make .xlam add-in functionalities workbook specific?

Currently my office is using an excel my team created to manage a certain kind of orders. This file has quite a lot of functionalities that are controlled by some hotkeys and a couple of userforms. Every couple of months when we want to add some new functions or repair some bugs every user needs to download the updated file. (The old file becomes unusable when a new version is available.)
​
To make this file more user friendly and to make it easier for us to manage the current version and distributing the new one I started to convert this file to an .xlam add in. I was inspired by a post a couple weeks/month ago about add in distributing in an office setting.
​
The problem I'm facing now is that ones the add in is loaded the add-in setting are used for every open workbook.
How I want the add in to be used is as follows:
When excel is started the add in tab is visible in the ribbon with 1 button visible. When this button is pressed a couple of sheets are added to the workbook with the basic data that is needed. And all the other buttons are now visible and enabled.
​
The problem is that once that activation button is pressed all the other buttons are also visible and usable in every other workbook the user has open or opens.
​
So, my question is, is it possible to make the buttons of the custom ribbon (visible or not visible) workbook specific? And this way the functionalities of the add in only available when the activation button is pressed in that specific workbook. And lastly making the variables defined in the add in also workbook specific?
​
Is this all possible with an .xlam add in or do I need to start with VTSO?
​
It is possible to do this within the file. In your callback, you can use
Call RefreshRibbon(Tag:=""), which won't return any macro matches (by design) and therefore all will be disabled. This is a great resource with several examples.
https://www.rondebruin.nl/win/s2/win013.htm

Modules in Project Explorer are not grouped anymore into modules, classes and forms

Modules in MS Office Project Explorer have always been grouped into forms, modules and classes, with "pluses" that allow to collapse or expand the groups. Either I have pressed some random hotkey, or the latest MS Office update messed it up, BUT now all my modules are just a list sorted by name (see the screenshot). It's the same in all Office programs. What has happened, and is there a remedy to this? I want my groups back :-(
I looked through all settings in VBA Editor, but I never found anything related to the problem.
Press the Toggle Folders button in your Project Explorer:
Alternatively use the Toggle Folders button in the context menu of the Project Explorer.

Save custom macro toolbar modifications in Excel 2011 for Mac

I produced several custom macros in Windows, modified the XML so that a custom Ribbon Tab was visible in the 2013 version of Windows, and everything was wonderful.
I'm now trying to produce equivalent functionality for Excel 2011 for Mac. I did the following: View >> Toolbars >> Custom Toolbars and Menu. I then went to the "Commands" toolbar >> Macros, and dragged SmileyFace macros to the main toolbar. I then changed the images, modified the text, and it worked locally.
For redundancy, I also added a new menu to "Toolbars and Menu" and added all my macros to that toolbar as well, which appeared as some sort of goofy, nebulous floating box. I attached the macros to the document using the "attach" button.
However, when I send the document to colleagues, the only thing that appears is that nebulous floating custom toolbar, with none of the macros mapped to buttons, and the buttons don't have my custom image.
How do I do this?
The most recent version of Excel 2011 (14.3.5) seems to save custom toolbars in a single file in specific user folder:
Users/[User]/Library/Application Support/Microsoft/Office/Preferences/Office 2011/Microsoft Excel Toolbars.xlsx
(original source here)
When I saved an Excel 2011 workbook with a custom toolbar on one Mac, and transferred it to another, the toolbar did not appear. When I coied the Microsoft Excel Toolbars.xlsx file over (and dropped it in the proper location), the toolbar did appear.
Note: This location may be specific to more recent versions of Office 2011; older versions seem to store them in Users/[User]/Library/Preferences/Microsoft/Office 2011.
Short-term, you may need to distribute the toolbar file along with the spreadsheet, as well as some means (via script and/or manual instruction) of copying it into the expected location.
<pure speculation>
Longer-term, maybe there's a way to override this default behavior and point to a 'local' copy of the toolbars stored in the distributed file itself. Or, maybe you can use the toolbar file as a template for the distributed spreadsheet.
</pure speculation>

Resources