NetOfficeFw / NetOffice

🌌 Create add-ins and automation code for Microsoft Office applications.
MIT License
700 stars 145 forks source link

Documentation #389

Closed chadknudson closed 5 months ago

chadknudson commented 1 year ago

I would like to contribute a little to the documentation for the project. One thing I found challenging was getting started with creating a COM AddIn for Microsoft Office. Getting the build working right, getting registration correct, dealing with 32-bit and 64-bit build targets, etc. were all hurdles that took a little time to work through. I put together a short walk through that gets a developer up and running with creating a new AddIn and being able to load the AddIn in Office under the debugger. This is a great starting point for someone new to the process. I wrote up a walk through that details all the processes required to get up and running with your first COM AddIn for Office. Is that of interest to you? Creating a COM Global AddIn for Microsoft Office using NetOfficeFW.docx ?

jozefizso commented 1 year ago

Hi @chadknudson, thanks for writing such documentation, this part is really not well documented.

Have you tried the build task which registers the Addin automatically?

https://github.com/NetOfficeFw/BuildTasks

Addin development should never require running Visual Studio as administrator. It's required if you're using regsvr32.exe to register the addin but that's not recommended to do, although old NetOffice tooling was using this way.

The addin can be developed as AnyCPU so there's no need to create multiple build platform targets.

This will simplify the development setup a lot.

chadknudson commented 1 year ago

I didn't know about the build task for NetOffice for registration - that will definitely simplify things. I will update the documentation to include that in the process. I was using RegAsm.exe to register the AddIn DLL in a post-build event and that required running Visual Studio as Administrator. I'm thrilled to get rid of that!

I thought that we had to create an x64 build to work in Office 64-bit. I didn't realize that we could use a single AddIn DLL with AnyCPU as the target architecture. That's pretty cool!

I wanted to do something to help the project out. As a former Microsoft Office engineer, I have to be very careful about the things I touch in terms of technology. Documentation is not something anyone can complain about :-)

chadknudson commented 1 year ago

I am working on a short tutorial walkthrough to demonstrate how to create an AddIn using NetOfficeFw. My first stage of the project is simply taking the reader through creating a new AddIn project and being able to run it in the debugger. I take the reader through the process of downloading and installing the Visual Studio Extensions for NetOfficeFw to have access to the NetOfficeFw project templates. I have them clone the NetOfficeBuildTasks repo and build that. Then I walk them through the process of creating a new NetOfficeFw AddIn project, modifying the project's build process to register the AddIn, and setting up Visual Studio to debug the AddIn inside the Word application.

I have the base tutorial project in a GitHub repository at https://github.com/chadknudson/WordAddinTutorial. All this project contains is the initial project from the Visual Studio extension and adding the custom MSBuild tasks to register the AddIn in the build process.

I don't have the build process quite right yet. When I do a Clean I get an error about being unable to load the WordApi assembly, so I imagine I'm removing the assemblies before the Clean target gets a chance to run. I get that when I attempt to do a Rebuild as well.

Once I get this nailed down properly, I think I will explore packaging up the custom build tasks in a NuGet and provide an install.ps1 file to modify the .csproj file for the developer so the process can be as simple as creating a new AddIn project and adding a NuGet reference for the custom build tasks.

chadknudson commented 1 year ago

I have written walk through tutorials on creating a custom task pane and customizing the Office Ribbon. I need to figure out the build process for the registration process though. I still don't have that quite right.

ashishpCACTUS commented 1 year ago

@chadknudson - Can you please share the documentation for custom task pane and Office Ribbon customisation ? The document attached is only for basic project creation

chadknudson commented 1 year ago

The documentation I am working on is still a work in progress. I'd appreciate any constructive criticism that you might have to offer and any suggestions on errors or omissions. My goal is to prepare a series of walk throughs to help a developer get started with writing Office AddIns and be able to perform a set of the most common tasks.

These are not yet complete and are still works in progress. I haven't finished the corresponding walkthrough projects and uploaded them to GitHub yet.

I am having some issues with the .csproj file for incorporating the NetOffice Custom MS Build Tasks in the build process. If you want to look at the code for the first walkthrough project and do a pull request I'm totally open to fixes and contributions. Ultimately it would be nice to publish the NetOffice Custom MS Build Tasks as a NuGet and have that automatically modify the .csproj file to handle that integration for the developer.

[Adding a Custom Task Pane to the Microsoft Office AddIn.docx](https://github.com/NetOfficeFw/NetOffice/files/11194648/Adding.a.Custom.Task.Pane.to.the.Microsoft.O

Customizing the Microsoft Word Ribbon.docx ffice.AddIn.docx)

jozefizso commented 1 year ago

Ultimately it would be nice to publish the NetOffice Custom MS Build Tasks as a NuGet and have that automatically modify the .csproj file to handle that integration for the developer.

I worked on this these days: https://github.com/NetOfficeFw/BuildTasks/compare/main...nuspec

chadknudson commented 1 year ago

Ultimately it would be nice to publish the NetOffice Custom MS Build Tasks as a NuGet and have that automatically modify the .csproj file to handle that integration for the developer.

I worked on this these days: NetOfficeFw/BuildTasks@main...nuspec

Thanks! That is awesome! I will incorporate that into the tutorials I am writing.

chadknudson commented 1 year ago

Did you publish NetOffice.Build to NuGet.org?

ashishpCACTUS commented 1 year ago

@chadknudson - Any update on the Tutorial walk through progress ?

regisin commented 1 year ago

Just wanted to bump this issue up. I'd be happy to help with documenting. Or at least a "Getting started" type of guide. But I can't figure it out for myself so that's hard :~

@chadknudson your document helped me run the addin example! Any progress on the build task route?

chadknudson commented 1 year ago

https://github.com/NetOfficeFw/BuildTasks

Did you publish this to NuGet.org? I didn't see it when I was looking for it.

jozefizso commented 1 year ago

Did you publish this to NuGet.org? I didn't see it when I was looking for it.

No, the build tools are not yet available as a nuget package.

jozefizso commented 1 year ago

NetOfficeFw/BuildTasks

Did you publish this to NuGet.org? I didn't see it when I was looking for it.

@chadknudson here is the NetOfficeFw.Build package: https://www.nuget.org/packages/NetOfficeFw.Build/

It requires a manual setup so the build tasks known which Office applications should the add-in be registered into.

I hope the instruction documents well how to use it.