You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/archive/guides/com-server-support.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,14 +4,18 @@ title: "COM Server Support"
4
4
Functions and macros created in an Excel-DNA add-in can be called directly from Excel VBA by using Application.Run(...). However, .NET also supports creating rich object models that are exported as COM libraries, which can be Tools->Referenced in VBA. Excel-DNA has some advanced support to host COM-exported objects from Excel-DNA add-ins, giving some advantages over the regular .NET ‘Register for COM interop’ hosting approach:
5
5
6
6
- COM objects that are created via the Excel-DNA COM server support will be active in the same AppDomain as the rest of the add-in, allowing direct shared access to static variables, internal caches etc.
7
+
7
8
- COM registration for classes hosted by Excel-DNA does not require administrative access (even when registered via RegSvr32.exe).
8
-
- Everything needed for the COM server can be packed in a single-file .xll add-in, including the type library used for IntelliSense support in VBA.
9
-
Mikael Katajamäki has written some detailed tutorial posts on his [Excel in Finance](http://mikejuniperhill.blogspot.com/) blog that explore this Excel-DNA feature, with detailed explanation, step-by-step instructions, screen shots and further links. See:
9
+
10
+
- Everything needed for the COM server can be packed in a single-file .xll add-in, including the type library used for IntelliSense support in VBA.
11
+
12
+
In addition to the description below, there is a sample project and a step-by-step instructions in the [Excel-DNA Samples repository](https://github.com/Excel-DNA/Samples/tree/master/DnaComServer). Note that these techniques would works equally well with code written in VB.NET, allowing you to port VB/VBA libraries to VB.NET with Excel-DNA and then use these from VBA.
13
+
14
+
Mikael Katajamäki has written some detailed tutorial posts on his [Excel in Finance](http://mikejuniperhill.blogspot.com/) blog that explore this Excel-DNA feature, with detailed explanation, step-by-step instructions, screen shots, and further links. Note that these project descriptions do not use the Excel-DNA Nuget packages. Therefore, the project layout is not current however, the implementation might still be instructive:
10
15
11
16
-[Interfacing C# and VBA with Excel-DNA (no intellisense support)](http://mikejuniperhill.blogspot.com/2014/03/interfacing-c-and-vba-with-exceldna-no.html)
12
-
-[Interfacing C# and VBA with Excel-DNA (with intellisense support)](http://mikejuniperhill.blogspot.com/2014/03/interfacing-c-and-vba-with-exceldna_16.html)
13
17
14
-
Note that these techniques would works equally well with code written in VB.NET, allowing you to port VB/VBA libraries to VB.NET with Excel-DNA and then use these from VBA.
18
+
-[Interfacing C# and VBA with Excel-DNA (with intellisense support)](http://mikejuniperhill.blogspot.com/2014/03/interfacing-c-and-vba-with-exceldna_16.html)
Copy file name to clipboardExpand all lines: docs/archive/guides/installing-your-add-in.md
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,25 +5,31 @@ Ease of deployment is one of the great advantages of making your Excel add-ins u
5
5
6
6
The issue addressed here is how to install your add-in into Excel, so that it will automatically load every time Excel is started.
7
7
8
+
## .NET Runtime
9
+
10
+
Excel-DNA supports add-in projects that target .NET Framework 4.x and/or .NET 6. When targeting .NET 6 the end-user must have the [.NET 6 Desktop runtime](https://dotnet.microsoft.com/en-us/download/dotnet/6.0) installed.
11
+
8
12
## Packing
9
13
10
-
First, you might find it useful to try the [Excel-DNA Packing Tool](exceldna-packing-tool.md) to create a single .xll for deployment.
14
+
As part of the add-in compilation, Excel-DNA creates single file packed add-ins (for 32 and 64 bit Excel) under a `publish` directory. These packed addins contain all the required dependencies and can be opened on another computer.
11
15
12
16
## Security
13
17
14
18
Note that most Excel-DNA features do not require administrator rights to run, or any registration to be dome before running the add-in. This includes the use of RTD servers as well as Ribbon and Custom Task Pane UI customization.
15
19
16
20
Office implements a comprehensive security system, which is accessed via the _File->Options, Trust Center_ dialog. Your Excel-DNA add-ins are subject to the security restrictions configured in the Trust Center. To operate in a secure environment I suggest you sign the packed .xll (using the signtool utility) and incorporate the certificate into the Office Trust Center, along with the macro setting to allow only digitally signed macros to be loaded.
17
21
22
+
As of March 2023, Microsoft is [testing an option whereby downloaded addins are blocked by default](https://insider.office.com/en-us/blog/block-untrusted-xll-add-ins-by-default). Such add-ins can be enabled according to [the instructions linked by the error message that Excel displays](https://support.microsoft.com/en-us/topic/excel-is-blocking-untrusted-xll-add-ins-by-default-1e3752e2-1177-4444-a807-7b700266a6fb).
23
+
18
24
## Options to just run once
19
25
20
-
- Run from Visual Studio. Set Project > Proprties > Debug to run Excel.exe (full path) and make .xll file the command line parameter. (And use a post build task to copy and rename the ExcelDna.xll to the bin/debug folder.)
26
+
- Run from Visual Studio. Building the add-in project should set debug properties that run Exceland load the add-in ready for debugging.
21
27
- Just manually File > Open the .xll file from Excel.
22
28
- VBA `Application.RegisterXLL(...)` can open it. (Workbooks.Open will not work.)
23
29
24
30
## Options to install permanently
25
31
26
-
- In Excel, just File > Options > Addins. Install as an ordinary addin, not as a COM add-in even though communication may be using COM.
32
+
- In Excel, just File > Options > Add-ins. Install as an ordinary addin, not as a COM add-in even though communication may be using COM.
27
33
- From VBA do
28
34
* Application.addins.Add `myfilename.xll`
29
35
* Application.addins("myTitle").Installed = True. Title is defined by .dna file Name="myTitle", not necessarily the file name.
- I created an adapter class – called `RxExcel` but I see it is still in the `RxAdapter.cs` file - to map the .NET 4 Rx types to the Excel-DNA fake types. The idea would be that any add-in doing Rx stuff would just include the RxExcel file.
30
-
31
-
I need this because I still want to target .NET 2.0 with Excel-DNA, so the `System.IObservable` is not available.
7
+
- To map the .NET Rx types to the Excel-DNA RTD-based mechanism, it is possible to use the following code:
Copy file name to clipboardExpand all lines: docs/archive/obsolete/integrating-with-vba.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: "Integrating with VBA"
3
3
---
4
-
Excel-DNA can make it easy to call between .Net and VBA. This means existing VBA code need not be rewritten. And end users are likely to find VBA much easier to develop in.
4
+
Excel-DNA can make it easy to call between .NET and VBA. This means existing VBA code need not be rewritten. And end users are likely to find VBA much easier to develop in.
5
5
6
6
To do this, create an Excel-DNA project, and register the a class that will be the entry point from VBA as follows:
It is important to only communicate with Excel when it is Ready. For example, if one displays a non modal dialog then the program may fail if it attempts to call a VBA routine in response to a button press while the user is also in the process of editing a cell. Intercepting Window Messages messages etc. can also produce errors even though they are on the main thread. And of course accessing Excel from a different thread is forbidden.
5
5
6
-
The best approach is to enqueue such work to execute on the main Excel thread when it is ready. Some support for initiating such cross-thread work is now (December 2012) implemented by Excel-DNA, and exposed as methods on the `ExcelDna.Integration.ExcelAsyncUtil` class.
6
+
The best approach is to enqueue such work to execute on the main Excel thread when it is ready. Some support for initiating such cross-thread work is now implemented by Excel-DNA, and exposed as methods on the `ExcelDna.Integration.ExcelAsyncUtil` class.
7
7
8
8
To try it you need to
9
9
- call `ExcelAsyncUtil.Initialize()` in your `AutoOpen()`.
Copy file name to clipboardExpand all lines: docs/guides-advanced/user-settings-and-the-xllconfig-file.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
title: "User Settings and the .xll.config File"
3
3
---
4
4
5
+
**NOTE:** The details below are applicable only to add-ins targeting .NET Framework 4.x. With .NET 6, the XML-based config files are no longer automatically loaded. Additionally, the `System.Configuration.ConfigurationManager` has limited backward compatibility. It is recommended to use [Microsoft.Extensions.Configuration](https://learn.microsoft.com/en-us/dotnet/core/extensions/configuration) and related libraries to use `AppSettings.json` or XML-based configuration files.
6
+
5
7
## Basic Usage
6
8
7
9
1. Make a file called `<TheAddInName>.xll.config` with this in:
0 commit comments