-
Install Node.js: Ensure Node.js is installed on your system. You can download it from nodejs.org.
-
Install Office Add-in CLI: Open a terminal and run the following command to install the Office Add-in CLI globally:
npm install -g yo generator-office
-
Install Visual Studio Code: Download and install Visual Studio Code.
-
Install Office Add-in Debugger Extension: In Visual Studio Code, go to the Extensions view (Ctrl+Shift+X) and install the "Office Add-in Debugger" extension.
This project uses Excel Custom Functions using a JavaScript-only Runtime
, the script type is JavaScript
and the project type is Excel Add-in
.
The generated project will have the following structure:
your-project-name/
├── .vscode/
├── node_modules/
├── src/
│ ├── commands/
│ ├── taskpane/
│ ├── assets/
│ ├── functions/
│ └── styles/
├── manifest.xml
├── package.json
└── webpack.config.js
-
Install Dependencies:
npm install
-
Start the Local Web Server a local excel file:
npm start
Or
-
Start the Local Web Server running a web browser excel file:
npm run start:web -- --document "https://url of your Excel document"
-
Sideload the Add-in:
- Open Excel.
- Go to the
Insert
tab. - Click
My Add-ins
>Manage My Add-ins
>Upload My Add-in
. - Select the
manifest.xml
file from your project directory.
-
Open the Task Pane: After sideloading, you should see your add-in's task pane. You can now start developing your add-in.
-
Edit Code: Open
src/taskpane/taskpane.html
andsrc/taskpane/taskpane.js
in Visual Studio Code to customize your add-in's UI and functionality.
-
Set Breakpoints: Open the files in Visual Studio Code and set breakpoints in your JavaScript code.
-
Run the Debugger: Press
F5
to start debugging. This will attach the debugger to Excel, and you can inspect variables, step through code, and troubleshoot issues.
-
Prepare for Production: Modify your add-in as needed for production. Ensure you have proper icons, descriptions, and a polished UI.
-
Host the Web App: Deploy your web app to a hosting service (e.g., Azure, AWS, Heroku).
-
Update Manifest: Update the
manifest.xml
file with the production URL of your hosted web app. -
Distribute the Add-in: You can distribute the
manifest.xml
file directly to users or submit your add-in to the Office Store.
This guide should help you get started with building an Excel add-in using Visual Studio Code and Node.js. If you have any specific questions or need further assistance, feel free to ask!