├── SpecialTopics
├── DynamicArrays
│ ├── Examples.xlsx
│ ├── DynamicArrays.csproj
│ ├── DynamicArrays.sln
│ ├── ArrayMap.cs
│ ├── ExampleFunctions.cs
│ ├── ArrayResizer.cs
│ └── README.md
├── IntelliSenseForVBAFunctions
│ ├── TempFunctions.xlsm
│ ├── TempFunctionsWithDescriptions.xlsm
│ ├── TempFunctions.IntelliSense.xml
│ └── README.md
└── RTD
│ ├── TimerRTD
│ ├── TimerRTD.csproj
│ ├── Functions.cs
│ ├── TimerRTD.sln
│ ├── DataSources.cs
│ └── RtdServer.cs
│ └── README.md
├── Testing
├── TestingSample
│ ├── Sample.Test
│ │ ├── TestBook.xlsx
│ │ ├── Sample.Test.csproj
│ │ └── ExcelTests.cs
│ ├── Sample
│ │ ├── Sample.csproj
│ │ └── Functions.cs
│ └── TestingSample.sln
└── README.md
├── Fundamentals
├── ArgumentTypeBasics
│ ├── ArgumentTypeBasics.xlsm
│ ├── ArgumentTypeBasics.vbproj
│ ├── ArgumentTypeBasics.sln
│ └── Functions.vb
└── RibbonBasics
│ ├── RibbonResources
│ ├── MagicWand.png
│ ├── Ribbon.xml
│ ├── RibbonResources.Designer.vb
│ └── RibbonResources.resx
│ ├── Functions.vb
│ ├── My Project
│ ├── Settings.settings
│ ├── Application.Designer.vb
│ ├── Application.myapp
│ ├── AssemblyInfo.vb
│ ├── Resources.Designer.vb
│ ├── Settings.Designer.vb
│ └── Resources.resx
│ ├── Ribbon.vb
│ ├── RibbonBasics.vbproj
│ ├── RibbonBasics.sln
│ ├── RibbonFromResources.md
│ └── README.md
├── VBA-to-.NET
├── FormulaEvaluateConvert
│ ├── FormulaEvaluate
│ │ ├── Test.xlsx
│ │ ├── My Project
│ │ │ ├── launchSettings.json
│ │ │ ├── Settings.settings
│ │ │ ├── Application.Designer.vb
│ │ │ ├── Application.myapp
│ │ │ ├── AssemblyInfo.vb
│ │ │ ├── Resources.Designer.vb
│ │ │ ├── Settings.Designer.vb
│ │ │ └── Resources.resx
│ │ ├── FormulaEvaluate.vbproj
│ │ ├── mFunHelpers.vb
│ │ ├── mExcelHelpers.vb
│ │ └── mExcelMacros.vb
│ ├── OriginalFiles
│ │ ├── clsMathParser.cls
│ │ ├── mExcelMacros.bas
│ │ ├── mMathSpecFun.bas
│ │ └── Analisis Numerico y Macros en Excel.xlsm
│ ├── FormulaEvaluate.sln
│ └── FormulaEvaluateConvert.md
├── Readme.md
└── WebRequestBasics
│ └── Readme.md
├── README.md
├── GettingStarted
└── InstallVisualStudio.md
├── .gitattributes
└── .gitignore
/SpecialTopics/DynamicArrays/Examples.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Excel-DNA/Tutorials/HEAD/SpecialTopics/DynamicArrays/Examples.xlsx
--------------------------------------------------------------------------------
/Testing/TestingSample/Sample.Test/TestBook.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Excel-DNA/Tutorials/HEAD/Testing/TestingSample/Sample.Test/TestBook.xlsx
--------------------------------------------------------------------------------
/Fundamentals/ArgumentTypeBasics/ArgumentTypeBasics.xlsm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Excel-DNA/Tutorials/HEAD/Fundamentals/ArgumentTypeBasics/ArgumentTypeBasics.xlsm
--------------------------------------------------------------------------------
/Fundamentals/RibbonBasics/RibbonResources/MagicWand.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Excel-DNA/Tutorials/HEAD/Fundamentals/RibbonBasics/RibbonResources/MagicWand.png
--------------------------------------------------------------------------------
/SpecialTopics/IntelliSenseForVBAFunctions/TempFunctions.xlsm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Excel-DNA/Tutorials/HEAD/SpecialTopics/IntelliSenseForVBAFunctions/TempFunctions.xlsm
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/FormulaEvaluate/Test.xlsx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Excel-DNA/Tutorials/HEAD/VBA-to-.NET/FormulaEvaluateConvert/FormulaEvaluate/Test.xlsx
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/OriginalFiles/clsMathParser.cls:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Excel-DNA/Tutorials/HEAD/VBA-to-.NET/FormulaEvaluateConvert/OriginalFiles/clsMathParser.cls
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/OriginalFiles/mExcelMacros.bas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Excel-DNA/Tutorials/HEAD/VBA-to-.NET/FormulaEvaluateConvert/OriginalFiles/mExcelMacros.bas
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/OriginalFiles/mMathSpecFun.bas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Excel-DNA/Tutorials/HEAD/VBA-to-.NET/FormulaEvaluateConvert/OriginalFiles/mMathSpecFun.bas
--------------------------------------------------------------------------------
/SpecialTopics/IntelliSenseForVBAFunctions/TempFunctionsWithDescriptions.xlsm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Excel-DNA/Tutorials/HEAD/SpecialTopics/IntelliSenseForVBAFunctions/TempFunctionsWithDescriptions.xlsm
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/OriginalFiles/Analisis Numerico y Macros en Excel.xlsm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Excel-DNA/Tutorials/HEAD/VBA-to-.NET/FormulaEvaluateConvert/OriginalFiles/Analisis Numerico y Macros en Excel.xlsm
--------------------------------------------------------------------------------
/Fundamentals/ArgumentTypeBasics/ArgumentTypeBasics.vbproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net472;net6.0-windows
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Fundamentals/RibbonBasics/Functions.vb:
--------------------------------------------------------------------------------
1 | Imports ExcelDna.Integration
2 |
3 | Public Module MyFunctions
4 |
5 |
6 | Public Function HelloDna(name As String) As String
7 | Return "Hello " & name
8 | End Function
9 |
10 | End Module
--------------------------------------------------------------------------------
/SpecialTopics/RTD/TimerRTD/TimerRTD.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net472;net6.0-windows
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/Testing/TestingSample/Sample/Sample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net472;net6.0-windows
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/FormulaEvaluate/My Project/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "Excel": {
4 | "commandName": "Executable",
5 | "executablePath": "C:\\Program Files\\Microsoft Office\\root\\Office16\\EXCEL.EXE",
6 | "commandLineArgs": "/x \"FormulaEvaluate-AddIn64.xll\""
7 | }
8 | }
9 | }
--------------------------------------------------------------------------------
/Fundamentals/RibbonBasics/My Project/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/FormulaEvaluate/My Project/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/SpecialTopics/DynamicArrays/DynamicArrays.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net472;net6.0-windows
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/FormulaEvaluate/FormulaEvaluate.vbproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net472
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Fundamentals/RibbonBasics/RibbonResources/Ribbon.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Fundamentals/RibbonBasics/My Project/Application.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.42000
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
--------------------------------------------------------------------------------
/SpecialTopics/RTD/TimerRTD/Functions.cs:
--------------------------------------------------------------------------------
1 | using ExcelDna.Integration;
2 |
3 | namespace TimerRTD
4 | {
5 | public static class Functions
6 | {
7 | public static object TimerNow()
8 | {
9 | return XlCall.RTD("TimerRTD.RtdServer", null, "NOW");
10 | }
11 |
12 | public static object TimerWave(double amplitude, double frequency)
13 | {
14 | return XlCall.RTD("TimerRTD.RtdServer", null, "WAVE", amplitude.ToString(), frequency.ToString());
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Fundamentals/RibbonBasics/My Project/Application.myapp:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 | false
5 | 0
6 | true
7 | 0
8 | 1
9 | true
10 |
11 |
--------------------------------------------------------------------------------
/Testing/TestingSample/Sample/Functions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Sample
8 | {
9 | public static class Functions
10 | {
11 | public static double AddThem(double input1, double input2)
12 | {
13 | // Change the calculation here to give the 'wrong' values and re-run the tests.
14 | // return input1 + input2 - 1;
15 | return input1 + input2;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/FormulaEvaluate/My Project/Application.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.42000
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/FormulaEvaluate/My Project/Application.myapp:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 | false
5 | 0
6 | true
7 | 0
8 | 1
9 | true
10 |
11 |
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/FormulaEvaluate/mFunHelpers.vb:
--------------------------------------------------------------------------------
1 | Imports System.Math
2 |
3 | Module mFunHelpers
4 | Function IsMissing(obj As Object) As Boolean
5 | IsMissing = obj Is Nothing
6 | End Function
7 |
8 | Function Sqr(d As Double)
9 | Sqr = d * d
10 | End Function
11 |
12 | Function Atn(d As Double)
13 | Atn = Atan(d)
14 | End Function
15 |
16 | Function Sgn(d As Double)
17 | Sgn = Sign(d)
18 | End Function
19 |
20 | Function MakeArray(ParamArray doubles() As Double) As Double()
21 | MakeArray = doubles
22 | End Function
23 | End Module
24 |
--------------------------------------------------------------------------------
/Testing/TestingSample/Sample.Test/Sample.Test.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net472;net6.0-windows
5 | true
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | PreserveNewest
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Tutorials
2 | Tutorial content and sample projects for Excel-DNA.
3 |
4 | ## Contents
5 |
6 | ### GettingStarted
7 | * [Installing Visual Studio](GettingStarted/InstallVisualStudio.md)
8 |
9 | ### Fundamentals
10 | * [UDF Argument Types in VBA and .NET](Fundamentals/ArgumentTypeBasics)
11 | * [Ribbon Basics](Fundamentals/RibbonBasics)
12 |
13 | ### Special Topics
14 | * [Dynamic Arrays](SpecialTopics/DynamicArrays)
15 | * [IntelliSense for VBA Functions](SpecialTopics/IntelliSenseForVBAFunctions)
16 | * [RTD](SpecialTopics/RTD)
17 |
18 | ### Testing
19 | * [Testing Helper Introduction](Testing)
20 |
21 | ## Topic ideas
22 | * All about arrays
23 | * IntelliSense inside and out
24 | * VBA to DNA (and back again)
25 | * Dealing with a deluge of data
26 |
--------------------------------------------------------------------------------
/VBA-to-.NET/Readme.md:
--------------------------------------------------------------------------------
1 | # VBA to .NET
2 |
3 | The **VBA to .NET** series discusses topics that might be of particular interest to programmers who are familiar with VBA and want to start using the .NET platform. General themes include
4 | * How to port code from VBA to VB.NET, and what the main differences are between these languages and environments.
5 | * How to perform common tasks in .NET where the libraries and code would be quite different to those used in VBA.
6 | * How to structure projects in .NET to use the code in a variety of ways - different platforms, in a cloud-hosted setting, or as an Excel add-in.
7 |
8 | ### [Web Request Basics](WebRequestBasics/Readme.md)
9 |
10 | A common programming task is to retrieve some information from a remote system via an HTTP web request. This tutorial gives a high-level view of how to aprroach this task, an example of how to get started with the simple case, and some pointers on where to look further.
11 |
--------------------------------------------------------------------------------
/Fundamentals/RibbonBasics/Ribbon.vb:
--------------------------------------------------------------------------------
1 | Imports System.Runtime.InteropServices
2 | Imports Microsoft.Office.Interop.Excel
3 | Imports ExcelDna.Integration.CustomUI
4 | Imports ExcelDna.Integration
5 | Imports RibbonBasics.My.Resources
6 |
7 |
8 | Public Class Ribbon
9 | Inherits ExcelRibbon
10 |
11 | Public Overrides Function GetCustomUI(RibbonID As String) As String
12 | Return RibbonResources.Ribbon ' The name here is the resource name that the ribbon xml has in the RibbonResources resource file
13 | End Function
14 |
15 | Public Overrides Function LoadImage(imageId As String) As Object
16 | ' This will return the image resource with the name specified in the image='xxxx' tag
17 | Return RibbonResources.ResourceManager.GetObject(imageId)
18 | End Function
19 | Public Sub OnSayHelloPressed(control As IRibbonControl)
20 | Dim app As Application
21 | Dim rng As Range
22 |
23 | app = ExcelDnaUtil.Application
24 | rng = app.Range("A1")
25 | rng.Value = "Hello from .NET!"
26 |
27 | End Sub
28 |
29 | End Class
30 |
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/FormulaEvaluate/mExcelHelpers.vb:
--------------------------------------------------------------------------------
1 | Imports ExcelDna.Integration
2 | Imports Microsoft.Office.Interop.Excel
3 |
4 | Friend Module mExcelHelpers
5 |
6 | Public Application As Application = ExcelDnaUtil.Application
7 |
8 | Function Cells() As Range
9 | Cells = Application.Cells
10 | End Function
11 | Function Range(cell1 As Object) As Range
12 | Range = Application.Range(cell1)
13 | End Function
14 | Function Range(cell1 As Object, cell2 As Object) As Range
15 | Range = Application.Range(cell1, cell2)
16 | End Function
17 | Function Charts() As Sheets
18 | Charts = Application.Charts
19 | End Function
20 | Function ActiveChart() As Chart
21 | ActiveChart = Application.ActiveChart
22 | End Function
23 | Function Sheets() As Sheets
24 | Sheets = Application.Sheets
25 | End Function
26 | Function ActiveSheet() As Object
27 | ActiveSheet = Application.ActiveSheet
28 | End Function
29 | Function Selection() As Object
30 | Selection = Application.Selection
31 | End Function
32 |
33 | End Module
34 |
--------------------------------------------------------------------------------
/Fundamentals/RibbonBasics/RibbonBasics.vbproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net472;net6.0-windows
4 | true
5 |
6 |
7 |
8 | PreserveNewest
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | True
18 | True
19 | RibbonResources.resx
20 |
21 |
22 |
23 |
24 | My.Resources
25 | ResXFileCodeGenerator
26 | RibbonResources.Designer.vb
27 |
28 |
29 |
--------------------------------------------------------------------------------
/SpecialTopics/RTD/TimerRTD/TimerRTD.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30717.126
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimerRTD", "TimerRTD.csproj", "{78EBE69C-1FDE-4A29-B18D-7D8024CC85E4}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {78EBE69C-1FDE-4A29-B18D-7D8024CC85E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {78EBE69C-1FDE-4A29-B18D-7D8024CC85E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {78EBE69C-1FDE-4A29-B18D-7D8024CC85E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {78EBE69C-1FDE-4A29-B18D-7D8024CC85E4}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {FF2E304F-1AEE-4B2D-861E-5B90D4707CC4}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/Fundamentals/RibbonBasics/RibbonBasics.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30517.126
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RibbonBasics", "RibbonBasics.vbproj", "{BC64C7ED-B1ED-4FF3-B286-041CC9D400FE}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {BC64C7ED-B1ED-4FF3-B286-041CC9D400FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {BC64C7ED-B1ED-4FF3-B286-041CC9D400FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {BC64C7ED-B1ED-4FF3-B286-041CC9D400FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {BC64C7ED-B1ED-4FF3-B286-041CC9D400FE}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {B64813DD-EEAE-429C-AEBE-D08ED5A7CFA5}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/SpecialTopics/DynamicArrays/DynamicArrays.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30517.126
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynamicArrays", "DynamicArrays.csproj", "{86BCC618-6225-42CD-BD32-D0A188BF2489}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {86BCC618-6225-42CD-BD32-D0A188BF2489}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {86BCC618-6225-42CD-BD32-D0A188BF2489}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {86BCC618-6225-42CD-BD32-D0A188BF2489}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {86BCC618-6225-42CD-BD32-D0A188BF2489}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {9768A2E3-E831-4C21-8BF9-ACB8334777C6}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/Fundamentals/ArgumentTypeBasics/ArgumentTypeBasics.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30517.126
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ArgumentTypeBasics", "ArgumentTypeBasics.vbproj", "{DE0E5693-45DE-414F-BD36-E2BB27566EAD}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {DE0E5693-45DE-414F-BD36-E2BB27566EAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {DE0E5693-45DE-414F-BD36-E2BB27566EAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {DE0E5693-45DE-414F-BD36-E2BB27566EAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {DE0E5693-45DE-414F-BD36-E2BB27566EAD}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {5D3363B5-4857-41B1-BF46-BD7009A586D5}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/FormulaEvaluate.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31112.23
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "FormulaEvaluate", "FormulaEvaluate\FormulaEvaluate.vbproj", "{2339F95A-6632-403F-9ED8-7CE80BB2CD04}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {2339F95A-6632-403F-9ED8-7CE80BB2CD04}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {2339F95A-6632-403F-9ED8-7CE80BB2CD04}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {2339F95A-6632-403F-9ED8-7CE80BB2CD04}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {2339F95A-6632-403F-9ED8-7CE80BB2CD04}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {2FDD05DA-2D03-4843-AB51-850AA0694CCC}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/Fundamentals/RibbonBasics/My Project/AssemblyInfo.vb:
--------------------------------------------------------------------------------
1 | Imports System
2 | Imports System.Reflection
3 | Imports System.Runtime.InteropServices
4 |
5 | ' General Information about an assembly is controlled through the following
6 | ' set of attributes. Change these attribute values to modify the information
7 | ' associated with an assembly.
8 |
9 | ' Review the values of the assembly attributes
10 |
11 | '
12 |
13 | '
14 | '
15 |
16 |
17 |
18 |
19 |
20 | 'The following GUID is for the ID of the typelib if this project is exposed to COM
21 |
22 |
23 | ' Version information for an assembly consists of the following four values:
24 | '
25 | ' Major Version
26 | ' Minor Version
27 | ' Build Number
28 | ' Revision
29 | '
30 | ' You can specify all the values or you can default the Build and Revision Numbers
31 | ' by using the '*' as shown below:
32 | '
33 |
34 | '
35 | '
36 |
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/FormulaEvaluate/My Project/AssemblyInfo.vb:
--------------------------------------------------------------------------------
1 | Imports System
2 | Imports System.Reflection
3 | Imports System.Runtime.InteropServices
4 |
5 | ' General Information about an assembly is controlled through the following
6 | ' set of attributes. Change these attribute values to modify the information
7 | ' associated with an assembly.
8 |
9 | ' Review the values of the assembly attributes
10 |
11 | '
12 |
13 | '
14 | '
15 |
16 |
17 |
18 |
19 |
20 | 'The following GUID is for the ID of the typelib if this project is exposed to COM
21 |
22 |
23 | ' Version information for an assembly consists of the following four values:
24 | '
25 | ' Major Version
26 | ' Minor Version
27 | ' Build Number
28 | ' Revision
29 | '
30 | ' You can specify all the values or you can default the Build and Revision Numbers
31 | ' by using the '*' as shown below:
32 | '
33 |
34 | '
35 | '
36 |
--------------------------------------------------------------------------------
/SpecialTopics/IntelliSenseForVBAFunctions/TempFunctions.IntelliSense.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
7 |
8 |
10 |
12 |
13 |
16 |
18 |
20 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Testing/TestingSample/TestingSample.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30621.155
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Test", "Sample.Test\Sample.Test.csproj", "{BF559676-9F49-4508-AAC7-AA824053ADF7}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample", "Sample\Sample.csproj", "{057CA235-D5C9-40F7-BFDB-217C43B50469}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {BF559676-9F49-4508-AAC7-AA824053ADF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {BF559676-9F49-4508-AAC7-AA824053ADF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {BF559676-9F49-4508-AAC7-AA824053ADF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {BF559676-9F49-4508-AAC7-AA824053ADF7}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {057CA235-D5C9-40F7-BFDB-217C43B50469}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {057CA235-D5C9-40F7-BFDB-217C43B50469}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {057CA235-D5C9-40F7-BFDB-217C43B50469}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {057CA235-D5C9-40F7-BFDB-217C43B50469}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {B3A86753-D27E-43F0-A049-1C9E257E2662}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/GettingStarted/InstallVisualStudio.md:
--------------------------------------------------------------------------------
1 | # Install Visual Studio
2 |
3 | [Visual Studio](https://visualstudio.microsoft.com) is the integrated development environment (IDE) used to develop .NET application and libraries, including Excel-DNA add-ins developed with .NET. I've made a step-by-step video guide that you can find on YouTube.
4 |
5 | [](http://www.youtube.com/watch?v=M-9jsOXVw_o "Excel-DNA - Install Visual Studio")
6 |
7 | Some notes are below.
8 |
9 | ### Notice the different 'Visual Studio' products and editions
10 |
11 | We are interested in the 'Visual Studio' product, and can then select one of the three editions to install.
12 |
13 | 
14 |
15 | Any of the three editions can be used for Excel-DNA developement.
16 | The Community and Professional editions have the same functionality, but differ in the cost and license restrictions. The Community edition is free but have limitation on use in Enterprise environments.
17 | [Details about Visual Studio editions](https://visualstudio.microsoft.com/vs/compare)
18 |
19 | ### Select the workload during installation
20 |
21 | During Visual Studio installation the main selection concerns the workloads and components to be installed.
22 |
23 | 
24 |
25 | For Excel-DNA development we require only the *.NET Desktop Development* workload to be installed. All the optional features may be deselected. Also note tate the *Office/Sharepoint tools* workload in not required for doing Excel-DNA development.
26 |
--------------------------------------------------------------------------------
/SpecialTopics/RTD/TimerRTD/DataSources.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Timers;
3 |
4 | namespace TimerRTD
5 | {
6 | // Represents a streaming source of 'current time' updates,
7 | // implementd by a simple timer
8 | public class NowDataSource: IDisposable
9 | {
10 | // This event 'publishes' new values of 'Now'
11 | public event Action NewValue;
12 |
13 | // The backing Timer object - it fires from a ThreadPool thread
14 | readonly Timer _timer;
15 |
16 | public NowDataSource()
17 | {
18 | _timer = new Timer(100);
19 | _timer.Elapsed += (s, e) => NewValue(DateTime.Now);
20 | _timer.Start();
21 | }
22 |
23 | // We use the IDisposable pattern to clean up any 'data source' resources
24 | // It's not really needed in this case, but shows where a clean-up step might appear
25 | public void Dispose()
26 | {
27 | _timer.Dispose();
28 | }
29 | }
30 |
31 | public class WaveDataSource : IDisposable
32 | {
33 | // Publish an event that 'publishes' new random values
34 | public event Action NewValue;
35 |
36 | double _amplitude;
37 | double _frequency;
38 | DateTime _start;
39 | Timer _timer;
40 |
41 | public WaveDataSource(double amplitude, double frequency)
42 | {
43 | _amplitude = amplitude;
44 | _frequency = frequency;
45 | _start = DateTime.UtcNow;
46 | _timer = new Timer(100);
47 | _timer.Elapsed += (s, e) => NewValue?.Invoke(CurrentValue());
48 | _timer.Start();
49 | }
50 |
51 | double CurrentValue()
52 | {
53 | double t = (DateTime.UtcNow - _start).TotalSeconds;
54 | return _amplitude * Math.Sin(t * 2 * Math.PI * _frequency);
55 | }
56 |
57 | public void Dispose()
58 | {
59 | _timer.Dispose();
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/SpecialTopics/RTD/TimerRTD/RtdServer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using ExcelDna.Integration;
6 | using ExcelDna.Integration.Rtd;
7 |
8 | namespace TimerRTD
9 | {
10 | [ComVisible(true)]
11 | public class RtdServer : ExcelRtdServer
12 | {
13 | Dictionary _dataSources;
14 |
15 | protected override bool ServerStart()
16 | {
17 | _dataSources = new Dictionary();
18 | return true;
19 | }
20 |
21 | protected override object ConnectData(Topic topic, IList topicInfo, ref bool newValues)
22 | {
23 | var sourceName = topicInfo.FirstOrDefault();
24 | if (sourceName == "NOW")
25 | {
26 | var source = new NowDataSource();
27 | source.NewValue += dateTime => topic.UpdateValue($"{dateTime:HH:mm:ss}");
28 | _dataSources[topic] = source;
29 | return null; // We could also return an initial value
30 | }
31 |
32 | if (sourceName == "WAVE")
33 | {
34 | // Figure out the other topic parameters, which are strings in the topicInfo list.
35 | // No error - assume we have two extra topic strings and they are numbers
36 | double.TryParse(topicInfo[1], out double amplitude);
37 | double.TryParse(topicInfo[2], out double frequency);
38 | var source = new WaveDataSource(amplitude, frequency);
39 | source.NewValue += val => topic.UpdateValue(val);
40 | _dataSources[topic] = source;
41 | return null;
42 | }
43 |
44 | // This is unexpected and an error in our code - the RTD Server is used with our own wrapper functions
45 | throw new ArgumentOutOfRangeException(nameof(topicInfo), $"Unknown topic {sourceName}");
46 | }
47 |
48 | protected override void DisconnectData(Topic topic)
49 | {
50 | _dataSources[topic].Dispose();
51 | _dataSources.Remove(topic);
52 | }
53 |
54 | protected override void ServerTerminate()
55 | {
56 | // All topics will already have been Disconnected
57 | // We can do final clean-up here
58 | }
59 |
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Fundamentals/RibbonBasics/RibbonFromResources.md:
--------------------------------------------------------------------------------
1 | # Project layout with ribbon and images in a resources file
2 |
3 |
4 | An alternative approach is to add the .xml file in a separate file and embed as a resource in the add-in.
5 | For complicated projects, this might be a better structure.
6 |
7 | I'll put the ribbon xml file and related resources (like images we show in the ribbon) into a project folder called `RibbonResources`.
8 |
9 | Steps to add the `.xml` file as a resource:
10 | 1. Add a new folder under our project to hold our ribbon resources - called e.g. `RibbonResources`
11 | 2. Add a new xml file called `Ribbon.xml` with the following content inside the `RibbonResources` folder:
12 |
13 | ```xml
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | ```
27 |
28 | 3. Add a new resources file to the project called `RibbonResources.resx`.
29 | 4. Into the resource file, `Add Existing File` and select the `RibbonResouces\Ribbon.xml` file. Check that it is called `Ribbon` - we'll use this name a bit later.
30 |
31 | 5. Take similar steps for an image, where the name of the image in the resources file matches the name in the `image` attribute in the ribbon markup.
32 |
33 | 6. The class will now explicitly get the ribbon markup and images from the resources class. It does this my overriding the `GetCustomUI` and `LoadImage` methods of the `ExcelRibbon` base class.
34 |
35 | ```vb
36 | Imports System.Runtime.InteropServices
37 | Imports ExcelDna.Integration.CustomUI
38 |
39 |
40 | Public Class Ribbon
41 | Inherits ExcelRibbon
42 |
43 | Public Overrides Function GetCustomUI(RibbonID As String) As String
44 | Return RibbonResources.Ribbon ' The name here is the resource name that the ribbon xml has in the RibbonResources resource file
45 | End Function
46 |
47 | Public Overrides Function LoadImage(imageId As String) As Object
48 | ' This will return the image resource with the name specified in the image='xxxx' tag
49 | Return RibbonResources.ResourceManager.GetObject(imageId)
50 | End Function
51 |
52 | Public Sub OnButtonPressed(control As IRibbonControl)
53 | MsgBox("Hello")
54 | End Sub
55 |
56 | End Class
57 | ```
58 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/Fundamentals/RibbonBasics/My Project/Resources.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.42000
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
15 | Namespace My.Resources
16 |
17 | 'This class was auto-generated by the StronglyTypedResourceBuilder
18 | 'class via a tool like ResGen or Visual Studio.
19 | 'To add or remove a member, edit your .ResX file then rerun ResGen
20 | 'with the /str option, or rebuild your VS project.
21 | '''
22 | ''' A strongly-typed resource class, for looking up localized strings, etc.
23 | '''
24 | _
28 | Friend Module Resources
29 |
30 | Private resourceMan As Global.System.Resources.ResourceManager
31 |
32 | Private resourceCulture As Global.System.Globalization.CultureInfo
33 |
34 | '''
35 | ''' Returns the cached ResourceManager instance used by this class.
36 | '''
37 | _
38 | Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
39 | Get
40 | If Object.ReferenceEquals(resourceMan, Nothing) Then
41 | Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("RibbonBasics.Resources", GetType(Resources).Assembly)
42 | resourceMan = temp
43 | End If
44 | Return resourceMan
45 | End Get
46 | End Property
47 |
48 | '''
49 | ''' Overrides the current thread's CurrentUICulture property for all
50 | ''' resource lookups using this strongly typed resource class.
51 | '''
52 | _
53 | Friend Property Culture() As Global.System.Globalization.CultureInfo
54 | Get
55 | Return resourceCulture
56 | End Get
57 | Set(ByVal value As Global.System.Globalization.CultureInfo)
58 | resourceCulture = value
59 | End Set
60 | End Property
61 | End Module
62 | End Namespace
63 |
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/FormulaEvaluate/My Project/Resources.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.42000
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
15 | Namespace My.Resources
16 |
17 | 'This class was auto-generated by the StronglyTypedResourceBuilder
18 | 'class via a tool like ResGen or Visual Studio.
19 | 'To add or remove a member, edit your .ResX file then rerun ResGen
20 | 'with the /str option, or rebuild your VS project.
21 | '''
22 | ''' A strongly-typed resource class, for looking up localized strings, etc.
23 | '''
24 | _
28 | Friend Module Resources
29 |
30 | Private resourceMan As Global.System.Resources.ResourceManager
31 |
32 | Private resourceCulture As Global.System.Globalization.CultureInfo
33 |
34 | '''
35 | ''' Returns the cached ResourceManager instance used by this class.
36 | '''
37 | _
38 | Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
39 | Get
40 | If Object.ReferenceEquals(resourceMan, Nothing) Then
41 | Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("FormulaEvaluate.Resources", GetType(Resources).Assembly)
42 | resourceMan = temp
43 | End If
44 | Return resourceMan
45 | End Get
46 | End Property
47 |
48 | '''
49 | ''' Overrides the current thread's CurrentUICulture property for all
50 | ''' resource lookups using this strongly typed resource class.
51 | '''
52 | _
53 | Friend Property Culture() As Global.System.Globalization.CultureInfo
54 | Get
55 | Return resourceCulture
56 | End Get
57 | Set(ByVal value As Global.System.Globalization.CultureInfo)
58 | resourceCulture = value
59 | End Set
60 | End Property
61 | End Module
62 | End Namespace
63 |
--------------------------------------------------------------------------------
/Fundamentals/RibbonBasics/My Project/Settings.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.42000
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
15 | Namespace My
16 |
17 | _
20 | Partial Friend NotInheritable Class MySettings
21 | Inherits Global.System.Configuration.ApplicationSettingsBase
22 |
23 | Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
24 |
25 | #Region "My.Settings Auto-Save Functionality"
26 | #If _MyType = "WindowsForms" Then
27 | Private Shared addedHandler As Boolean
28 |
29 | Private Shared addedHandlerLockObject As New Object
30 |
31 | _
32 | Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
33 | If My.Application.SaveMySettingsOnExit Then
34 | My.Settings.Save()
35 | End If
36 | End Sub
37 | #End If
38 | #End Region
39 |
40 | Public Shared ReadOnly Property [Default]() As MySettings
41 | Get
42 |
43 | #If _MyType = "WindowsForms" Then
44 | If Not addedHandler Then
45 | SyncLock addedHandlerLockObject
46 | If Not addedHandler Then
47 | AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
48 | addedHandler = True
49 | End If
50 | End SyncLock
51 | End If
52 | #End If
53 | Return defaultInstance
54 | End Get
55 | End Property
56 | End Class
57 | End Namespace
58 |
59 | Namespace My
60 |
61 | _
64 | Friend Module MySettingsProperty
65 |
66 | _
67 | Friend ReadOnly Property Settings() As Global.RibbonBasics.My.MySettings
68 | Get
69 | Return Global.RibbonBasics.My.MySettings.Default
70 | End Get
71 | End Property
72 | End Module
73 | End Namespace
74 |
--------------------------------------------------------------------------------
/Testing/TestingSample/Sample.Test/ExcelTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Xunit;
3 | using ExcelDna.Testing;
4 | using Microsoft.Office.Interop.Excel;
5 | using ExcelDna.Integration;
6 |
7 | namespace Sample.Test
8 | {
9 | // The path give here is relative to the output directory of the test project.
10 | // Setting an AddIn options here will request the test runner to load this add-in into Excel before the tests start.
11 | // The name here excludes the ".xll" or "64.xll" suffix. The test runner will choose according to the Excel bitness where it runs.
12 | #if NETFRAMEWORK
13 | [ExcelTestSettings(AddIn = @"..\..\..\..\Sample\bin\Debug\net6.0-windows\Sample-AddIn")]
14 | #else
15 | [ExcelTestSettings(AddIn = @"..\..\..\..\Sample\bin\Debug\net472\Sample-AddIn")]
16 | #endif
17 |
18 | public class ExcelTests : IDisposable
19 | {
20 | // This workbook will be available to all tests in the class
21 | Workbook _testWorkbook;
22 |
23 | // The test class constructor will configure the required environment for the tests in the class.
24 | // In this case it creates a new Workbook that will be shared by the tests
25 | public ExcelTests()
26 | {
27 | var app = Util.Application;
28 | _testWorkbook = app.Workbooks.Add();
29 | }
30 |
31 | // Clean-up for the class is in the IDisposable.Dispose implementation
32 | public void Dispose()
33 | {
34 | _testWorkbook.Close(SaveChanges: false);
35 | }
36 |
37 | // This test just interacts with Excel
38 | [ExcelFact]
39 | public void ExcelCanAddNumbers()
40 | {
41 | Worksheet ws = (Worksheet) _testWorkbook.Sheets[1];
42 |
43 | ws.Range["A1"].Value = 2.0;
44 | ws.Range["A2"].Value = 3.0;
45 | ws.Range["A3"].Formula = "=A1 + A2";
46 |
47 | var result = ws.Range["A3"].Value;
48 |
49 | Assert.Equal(5.0, result);
50 | }
51 |
52 | // This test depends on the AddIn value set in the class's ExcelTestSettings attributes
53 | // With the Sample-AddIn loaded, the function should work correctly.
54 | [ExcelFact]
55 | public void AddInCanAddNumbers()
56 | {
57 | Worksheet ws = (Worksheet) _testWorkbook.Sheets[1];
58 |
59 | ws.Range["A1"].Value = 2.0;
60 | ws.Range["A2"].Value = 3.0;
61 | ws.Range["A3"].Formula = "=AddThem(A1, A2)";
62 |
63 | var result = ws.Range["A3"].Value;
64 |
65 | Assert.Equal(5.0, result);
66 | }
67 |
68 | // Before this test is run, a pre-created workbook will be loaded
69 | // It has been added to the test project and configured to always be copied to the output directory
70 | [ExcelFact(Workbook = "TestBook.xlsx")]
71 | public void WorkbookCheckIsOK()
72 | {
73 | // Get the pre-loaded workbook using the Util.Workbook property
74 | var wb = Util.Workbook;
75 | Worksheet ws = (Worksheet) wb.Sheets["Check"];
76 | Util.Application.CalculateFull();
77 |
78 | var result = ws.Range["A1"].Value;
79 |
80 | Assert.Equal("OK", result);
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/VBA-to-.NET/FormulaEvaluateConvert/FormulaEvaluate/My Project/Settings.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.42000
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 |
15 | Namespace My
16 |
17 | _
20 | Partial Friend NotInheritable Class MySettings
21 | Inherits Global.System.Configuration.ApplicationSettingsBase
22 |
23 | Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings)
24 |
25 | #Region "My.Settings Auto-Save Functionality"
26 | #If _MyType = "WindowsForms" Then
27 | Private Shared addedHandler As Boolean
28 |
29 | Private Shared addedHandlerLockObject As New Object
30 |
31 | _
32 | Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs)
33 | If My.Application.SaveMySettingsOnExit Then
34 | My.Settings.Save()
35 | End If
36 | End Sub
37 | #End If
38 | #End Region
39 |
40 | Public Shared ReadOnly Property [Default]() As MySettings
41 | Get
42 |
43 | #If _MyType = "WindowsForms" Then
44 | If Not addedHandler Then
45 | SyncLock addedHandlerLockObject
46 | If Not addedHandler Then
47 | AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
48 | addedHandler = True
49 | End If
50 | End SyncLock
51 | End If
52 | #End If
53 | Return defaultInstance
54 | End Get
55 | End Property
56 | End Class
57 | End Namespace
58 |
59 | Namespace My
60 |
61 | _
64 | Friend Module MySettingsProperty
65 |
66 | _
67 | Friend ReadOnly Property Settings() As Global.FormulaEvaluate.My.MySettings
68 | Get
69 | Return Global.FormulaEvaluate.My.MySettings.Default
70 | End Get
71 | End Property
72 | End Module
73 | End Namespace
74 |
--------------------------------------------------------------------------------
/Fundamentals/RibbonBasics/RibbonResources/RibbonResources.Designer.vb:
--------------------------------------------------------------------------------
1 | '------------------------------------------------------------------------------
2 | '
3 | ' This code was generated by a tool.
4 | ' Runtime Version:4.0.30319.42000
5 | '
6 | ' Changes to this file may cause incorrect behavior and will be lost if
7 | ' the code is regenerated.
8 | '
9 | '------------------------------------------------------------------------------
10 |
11 | Option Strict On
12 | Option Explicit On
13 |
14 | Imports System
15 |
16 | Namespace My.Resources
17 |
18 | 'This class was auto-generated by the StronglyTypedResourceBuilder
19 | 'class via a tool like ResGen or Visual Studio.
20 | 'To add or remove a member, edit your .ResX file then rerun ResGen
21 | 'with the /str option, or rebuild your VS project.
22 | '''
23 | ''' A strongly-typed resource class, for looking up localized strings, etc.
24 | '''
25 | _
28 | Friend Class RibbonResources
29 |
30 | Private Shared resourceMan As Global.System.Resources.ResourceManager
31 |
32 | Private Shared resourceCulture As Global.System.Globalization.CultureInfo
33 |
34 | _
35 | Friend Sub New()
36 | MyBase.New
37 | End Sub
38 |
39 | '''
40 | ''' Returns the cached ResourceManager instance used by this class.
41 | '''
42 | _
43 | Friend Shared ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
44 | Get
45 | If Object.ReferenceEquals(resourceMan, Nothing) Then
46 | Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("RibbonBasics.RibbonResources", GetType(RibbonResources).Assembly)
47 | resourceMan = temp
48 | End If
49 | Return resourceMan
50 | End Get
51 | End Property
52 |
53 | '''
54 | ''' Overrides the current thread's CurrentUICulture property for all
55 | ''' resource lookups using this strongly typed resource class.
56 | '''
57 | _
58 | Friend Shared Property Culture() As Global.System.Globalization.CultureInfo
59 | Get
60 | Return resourceCulture
61 | End Get
62 | Set
63 | resourceCulture = value
64 | End Set
65 | End Property
66 |
67 | '''
68 | ''' Looks up a localized resource of type System.Drawing.Bitmap.
69 | '''
70 | Friend Shared ReadOnly Property MagicWand() As System.Drawing.Bitmap
71 | Get
72 | Dim obj As Object = ResourceManager.GetObject("MagicWand", resourceCulture)
73 | Return CType(obj,System.Drawing.Bitmap)
74 | End Get
75 | End Property
76 |
77 | '''
78 | ''' Looks up a localized string similar to <?xml version="1.0" encoding="utf-8" ?>
79 | '''<customUI xmlns='http://schemas.microsoft.com/office/2009/07/customui' loadImage='LoadImage'>
80 | ''' <ribbon>
81 | ''' <tabs>
82 | ''' <tab id='tab1' label='My Tab'>
83 | ''' <group id='group1' label='My Group'>
84 | ''' <button id='button1' label='My Button' onAction='OnButtonPressed' image='MagicWand'/>
85 | ''' </group>
86 | ''' </tab>
87 | ''' </tabs>
88 | ''' </ribbon>
89 | '''</customUI>.
90 | '''
91 | Friend Shared ReadOnly Property Ribbon() As String
92 | Get
93 | Return ResourceManager.GetString("Ribbon", resourceCulture)
94 | End Get
95 | End Property
96 | End Class
97 | End Namespace
98 |
--------------------------------------------------------------------------------
/SpecialTopics/DynamicArrays/ArrayMap.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using ExcelDna.Integration;
3 | using static ExcelDna.Integration.XlCall;
4 |
5 | public static class ArrayMapFunctions
6 | {
7 | // This helper function is converted from https://github.com/Excel-DNA/Samples/blob/master/ArrayMap/Functions.vb
8 | [ExcelFunction(Description = "Evaluates the two-argument function for every value in the first and second inputs. " + "Takes a single value and any rectangle, or one row and one column, or one column and one row.")]
9 | public static object dnaArrayMap2([ExcelArgument(Description = "The function to evaluate - either enter the name without any quotes or brackets (for .xll functions), or as a string (for VBA functions)")] object function, [ExcelArgument(Description = "The input value(s) for the first argument (row, column or rectangular range) ")] object input1, [ExcelArgument(Description = "The input value(s) for the second argument (row, column or rectangular range) ")] object input2)
10 | {
11 | {
12 | Func