How to create a custom Excel desktop Add to

I would like to create an excel Add in which additional toolbars and menu buttons are created. But I want this addon to load only when a certain book is opened. I do not want to download Addin if any workbook is open.

I would like to know what are the possible ways to solve this problem, and what is the best approach to implement this Add in (XLA or VSTO or COM Addin).

I do not want the user to know my Addin path, the VbA code needed to load / initialize addin.

+4
source share
3 answers

This sounds good for the VSTO Document project; unlike add-ons that extend the entire application and as such apply to any open document, the draft VSTO document is the configuration of a specific document to which additional code is added.

+5
source

Create a toolbar at the beginning, but set the visibility of the toolbar to false. Grab the book opened by the event handler for the AddIn.Application.WorkbookOpen event, and determine if the workbook is specific. At this point, you can set the visibility of the toolbar.

You can also capture the AddIn.Application.WorkbookActivate event and hide the toolbar again if the active book is not a specific book.

Remember to specify the member variable declared at the ThisAddIn level to save the link to the toolbar!

+4
source

If you really want addin to load when you open a specific book, why not load it into the Open event of the corresponding book

' code in the ThisWorkbook module Private Sub Workbook_Open() Dim wb As Workbook On Error Resume Next Set wb = Workbooks("myAddin.xla") If wb Is Nothing Then Set wb = Application.Workbooks.Open("c:\path\myAddin.xls") End If End Sub 

Alternatively, any other workbook or Addin can embed code to interfere with Excel application-level events, such as Workbook.Open, and if the name of the newly opened work is something you are interested in doing, that is, loading Addin

+2
source

Source: https://habr.com/ru/post/1313104/


All Articles