-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add sample for Word add-in using .NET 6
- Loading branch information
Showing
5 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
using NetOffice.Tools; | ||
using NetOffice.WordApi.Tools; | ||
|
||
namespace WordAddinCore | ||
{ | ||
[ComVisible(true)] | ||
[Guid("44408BE8-1C1A-4E80-93A5-3FE1B54B4384")] | ||
[ProgId("NetOfficeSamples.WordAddinCore")] | ||
public class Addin : COMAddin | ||
{ | ||
public Addin() | ||
{ | ||
OnStartupComplete += Addin_OnStartupComplete; | ||
OnDisconnection += Addin_OnDisconnection; | ||
} | ||
|
||
private void Addin_OnStartupComplete(ref Array custom) | ||
{ | ||
var appName = this.Application.Name; | ||
var appVersion = this.Application.Version; | ||
var appBuild = this.Application.Build; | ||
Trace.WriteLine($"Addin connected to {appName} version {appVersion} ({appBuild})."); | ||
} | ||
|
||
private void Addin_OnDisconnection(ext_DisconnectMode removeMode, ref Array custom) | ||
{ | ||
Trace.WriteLine($"Addin will shutdown."); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"profiles": { | ||
"Word 32-bit": { | ||
"commandName": "Executable", | ||
"executablePath": "C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\WINWORD.EXE" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0-windows</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<EnableComHosting>true</EnableComHosting> | ||
<Platforms>x86;x64</Platforms> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\Source\Word\WordApi.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.5.33516.290 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WordAddinCore", "WordAddinCore.csproj", "{A3A7189F-3D99-47F7-A451-ECC7003744E6}" | ||
EndProject | ||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WordApi", "..\..\..\Source\Word\WordApi.csproj", "{260973C4-E060-4007-B264-9886B793646E}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{A3A7189F-3D99-47F7-A451-ECC7003744E6}.Debug|Any CPU.ActiveCfg = Debug|x86 | ||
{A3A7189F-3D99-47F7-A451-ECC7003744E6}.Debug|Any CPU.Build.0 = Debug|x86 | ||
{A3A7189F-3D99-47F7-A451-ECC7003744E6}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{A3A7189F-3D99-47F7-A451-ECC7003744E6}.Release|Any CPU.Build.0 = Release|Any CPU | ||
{260973C4-E060-4007-B264-9886B793646E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{260973C4-E060-4007-B264-9886B793646E}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{260973C4-E060-4007-B264-9886B793646E}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{260973C4-E060-4007-B264-9886B793646E}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {6F19A0F2-ADA1-417B-8035-646401EFB9FF} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
C:\Windows\SysWOW64\regsvr32.exe /s WordAddinCore.comhost.dll | ||
:: C:\Windows\System32\regsvr32.exe /s WordAddin.comhost.dll | ||
|
||
reg add "HKEY_CURRENT_USER\Software\Microsoft\Office\Word\Addins\NetOfficeSamples.WordAddinCore" /f /v LoadBehavior /t REG_DWORD /d 3 | ||
reg add "HKEY_CURRENT_USER\Software\Microsoft\Office\Word\Addins\NetOfficeSamples.WordAddinCore" /f /v FriendlyName /t REG_SZ /d "Word Addin (.NET 6)" | ||
reg add "HKEY_CURRENT_USER\Software\Microsoft\Office\Word\Addins\NetOfficeSamples.WordAddinCore" /f /v Description /t REG_SZ /d "Sample addin running in .NET 6" |