diff --git a/.config/samples-config-v3.json b/.config/samples-config-v3.json
index fb8327c1d..f86307601 100644
--- a/.config/samples-config-v3.json
+++ b/.config/samples-config-v3.json
@@ -391,17 +391,18 @@
"suggested": false
},
{
- "id": "hello-world-teams-tab-and-outlook-add-in",
- "shortId": "helloworld-outlook",
+ "id": "hello-world-teams-tab-and-office-add-in",
+ "shortId": "helloworld-office",
"onboardDate": "2023-03-02",
- "title": "Hello World Teams Tab and Outlook add-in",
- "shortDescription": "A hello world project that contains both Teams Tab and Outlook add-in capability",
- "fullDescription": "Microsoft Teams supports the ability to run web-based UI inside \"custom tabs\" that users can install either for just themselves (personal tabs) or within a team or group chat context. Outlook add-ins are integrations built by third parties into Outlook by using our web-based platform. Now you have the ability to create a single unit of distribution for all your Microsoft 365 extensions by using the same manifest format and schema, based on the current JSON-formatted Teams manifest.",
+ "title": "Hello World Teams Tab and Office add-in",
+ "shortDescription": "A hello world project that contains both Teams Tab and Office add-in capability",
+ "fullDescription": "Microsoft Teams supports the ability to run web-based UI inside \"custom tabs\" that users can install either for just themselves (personal tabs) or within a team or group chat context. Office add-ins are integrations built by third parties into Office by using our web-based platform. Now you have the ability to create a single unit of distribution for all your Microsoft 365 extensions by using the same manifest format and schema, based on the current JSON-formatted Teams manifest.",
"types": [
"Tab"
],
"tags": [
"Tab",
+ "Office Add-in",
"Outlook Add-in"
],
"time": "5min to run",
diff --git a/hello-world-teams-tab-and-outlook-add-in/.gitignore b/hello-world-teams-tab-and-office-add-in/.gitignore
similarity index 92%
rename from hello-world-teams-tab-and-outlook-add-in/.gitignore
rename to hello-world-teams-tab-and-office-add-in/.gitignore
index 75b59b711..18e94fecc 100644
--- a/hello-world-teams-tab-and-outlook-add-in/.gitignore
+++ b/hello-world-teams-tab-and-office-add-in/.gitignore
@@ -1,6 +1,5 @@
# TeamsFx files
env/.env.*.user
-env/.env.local
.DS_Store
.localConfigs
diff --git a/hello-world-teams-tab-and-outlook-add-in/.vscode/extensions.json b/hello-world-teams-tab-and-office-add-in/.vscode/extensions.json
similarity index 100%
rename from hello-world-teams-tab-and-outlook-add-in/.vscode/extensions.json
rename to hello-world-teams-tab-and-office-add-in/.vscode/extensions.json
diff --git a/hello-world-teams-tab-and-outlook-add-in/.vscode/launch.json b/hello-world-teams-tab-and-office-add-in/.vscode/launch.json
similarity index 70%
rename from hello-world-teams-tab-and-outlook-add-in/.vscode/launch.json
rename to hello-world-teams-tab-and-office-add-in/.vscode/launch.json
index d39085f8b..98a7868fc 100644
--- a/hello-world-teams-tab-and-outlook-add-in/.vscode/launch.json
+++ b/hello-world-teams-tab-and-office-add-in/.vscode/launch.json
@@ -1,6 +1,36 @@
{
"version": "0.2.0",
"configurations": [
+ {
+ "name": "Debug in Word Desktop (Edge Chromium)",
+ "type": "msedge",
+ "request": "attach",
+ "port": 9229,
+ "timeout": 600000,
+ "webRoot": "${workspaceRoot}/add-in/",
+ "preLaunchTask": "Start Word Add-in Locally",
+ "postDebugTask": "Stop Debug"
+ },
+ {
+ "name": "Debug in Excel Desktop (Edge Chromium)",
+ "type": "msedge",
+ "request": "attach",
+ "port": 9229,
+ "timeout": 600000,
+ "webRoot": "${workspaceRoot}/add-in/",
+ "preLaunchTask": "Start Excel Add-in Locally",
+ "postDebugTask": "Stop Debug"
+ },
+ {
+ "name": "Debug in PowerPoint Desktop (Edge Chromium)",
+ "type": "msedge",
+ "request": "attach",
+ "port": 9229,
+ "timeout": 600000,
+ "webRoot": "${workspaceRoot}/add-in/",
+ "preLaunchTask": "Start PowerPoint Add-in Locally",
+ "postDebugTask": "Stop Debug"
+ },
{
"name": "Debug in Outlook Desktop (Edge Chromium)",
"type": "msedge",
@@ -8,7 +38,7 @@
"port": 9229,
"timeout": 600000,
"webRoot": "${workspaceRoot}/add-in/",
- "preLaunchTask": "Start Add-in Locally",
+ "preLaunchTask": "Start Outlook Add-in Locally",
"postDebugTask": "Stop Debug"
},
{
diff --git a/hello-world-teams-tab-and-outlook-add-in/.vscode/settings.json b/hello-world-teams-tab-and-office-add-in/.vscode/settings.json
similarity index 100%
rename from hello-world-teams-tab-and-outlook-add-in/.vscode/settings.json
rename to hello-world-teams-tab-and-office-add-in/.vscode/settings.json
diff --git a/hello-world-teams-tab-and-outlook-add-in/.vscode/tasks.json b/hello-world-teams-tab-and-office-add-in/.vscode/tasks.json
similarity index 74%
rename from hello-world-teams-tab-and-outlook-add-in/.vscode/tasks.json
rename to hello-world-teams-tab-and-office-add-in/.vscode/tasks.json
index dffe951cd..8737a230d 100644
--- a/hello-world-teams-tab-and-outlook-add-in/.vscode/tasks.json
+++ b/hello-world-teams-tab-and-office-add-in/.vscode/tasks.json
@@ -116,21 +116,69 @@
"showReuseMessage": false
}
},
+ {
+ "label": "Debug: Excel Desktop",
+ "type": "npm",
+ "script": "start:desktop:excel",
+ "options": {
+ "cwd": "${workspaceFolder}/add-in/"
+ },
+ "presentation": {
+ "clear": true,
+ "panel": "dedicated"
+ },
+ "problemMatcher": [],
+ "dependsOn": [
+ "Install"
+ ]
+ },
{
"label": "Debug: Outlook Desktop",
"type": "npm",
- "script": "start:desktop -- --app outlook",
+ "script": "start:desktop:outlook",
"options": {
"cwd": "${workspaceFolder}/add-in/"
},
+ "presentation": {
+ "clear": true,
+ "panel": "dedicated"
+ },
+ "problemMatcher": [],
"dependsOn": [
"Install"
- ],
+ ]
+ },
+ {
+ "label": "Debug: PowerPoint Desktop",
+ "type": "npm",
+ "script": "start:desktop:powerpoint",
+ "options": {
+ "cwd": "${workspaceFolder}/add-in/"
+ },
"presentation": {
"clear": true,
- "panel": "dedicated",
+ "panel": "dedicated"
},
- "problemMatcher": []
+ "problemMatcher": [],
+ "dependsOn": [
+ "Install"
+ ]
+ },
+ {
+ "label": "Debug: Word Desktop",
+ "type": "npm",
+ "script": "start:desktop:word",
+ "options": {
+ "cwd": "${workspaceFolder}/add-in/"
+ },
+ "presentation": {
+ "clear": true,
+ "panel": "dedicated"
+ },
+ "problemMatcher": [],
+ "dependsOn": [
+ "Install"
+ ]
},
{
"label": "Dev Server",
@@ -209,7 +257,31 @@
"problemMatcher": []
},
{
- "label": "Start Add-in Locally",
+ "label": "Start Word Add-in Locally",
+ "dependsOn": [
+ "Create resources",
+ "Debug: Word Desktop"
+ ],
+ "dependsOrder": "sequence"
+ },
+ {
+ "label": "Start Excel Add-in Locally",
+ "dependsOn": [
+ "Create resources",
+ "Debug: Excel Desktop"
+ ],
+ "dependsOrder": "sequence"
+ },
+ {
+ "label": "Start PowerPoint Add-in Locally",
+ "dependsOn": [
+ "Create resources",
+ "Debug: PowerPoint Desktop"
+ ],
+ "dependsOrder": "sequence"
+ },
+ {
+ "label": "Start Outlook Add-in Locally",
"dependsOn": [
"Create resources",
"Debug: Outlook Desktop"
diff --git a/hello-world-teams-tab-and-outlook-add-in/README.md b/hello-world-teams-tab-and-office-add-in/README.md
similarity index 90%
rename from hello-world-teams-tab-and-outlook-add-in/README.md
rename to hello-world-teams-tab-and-office-add-in/README.md
index 6e5969060..37c455b3a 100644
--- a/hello-world-teams-tab-and-outlook-add-in/README.md
+++ b/hello-world-teams-tab-and-office-add-in/README.md
@@ -5,28 +5,28 @@ languages:
products:
- office-teams
- office
-name: Hello World Teams Tab and Outlook add-in
-urlFragment: officedev-teamsfx-samples-tab-hello-world-teams-tab-and-outlook-add-in
-description: A hello world project that contains both Teams Tab and Outlook add-in capability.
+name: Hello World Teams Tab and Office add-in
+urlFragment: officedev-teamsfx-samples-tab-hello-world-teams-tab-and-office-add-in
+description: A hello world project that contains both Teams Tab and Office add-in capability.
extensions:
createdDate: "2023-03-02"
---
-# Getting Started with Hello World Teams Tab and Outlook add-in Sample
+# Getting Started with Hello World Teams Tab and Office add-in Sample
Microsoft Teams supports the ability to run web-based UI inside "custom tabs" that users can install either for just themselves (personal tabs) or within a team or group chat context.
-Outlook add-ins are integrations built by third parties into Outlook by using our web-based platform.
+Office add-ins are integrations built by third parties into Office by using our web-based platform.
Now you have the ability to create a single unit of distribution for all your Microsoft 365 extensions by using the same manifest format and schema, based on the current JSON-formatted Teams manifest.
## This sample illustrates
-- How a Teams Tab and an Outlook add-in share the same JSON manifest in one project.
+- How a Teams Tab and an Office add-in share the same JSON manifest in one project.
## Prerequisites to use this sample
-- [Node.js](https://nodejs.org/), supported versions: 16, 18
-- Edge or Chrome installed for debugging Teams Tab. Edge installed for debugging Outlook add-in.
+- [Node.js](https://nodejs.org/), supported versions: 18, 20
+- Edge or Chrome installed for debugging Teams Tab. Edge installed for debugging Office add-in.
- Outlook for Windows: Beta Channel, Build 16320 or higher. Follow [this link](https://github.com/OfficeDev/TeamsFx/wiki/How-to-switch-Outlook-client-update-channel-and-verify-Outlook-client-build-version) for information about how to update channels and check your Outlook client build version.
- An M365 account. If you do not have M365 account, apply one from [M365 developer program](https://developer.microsoft.com/en-us/microsoft-365/dev-program)
- [Teams Toolkit Visual Studio Code Extension](https://aka.ms/teams-toolkit) version 5.0.0 and higher or [Teams Toolkit CLI](https://aka.ms/teams-toolkit-cli)
@@ -43,12 +43,12 @@ Now you have the ability to create a single unit of distribution for all your Mi
After installing the app in Teams when prompted, it will launch and you'll be able to view the tab app.

-### Debug Outlook add-in
+### Debug Office add-in
-- Please note that the same M365 account should be used both in Teams Toolkit and Outlook.
+- Please note that the same M365 account should be used both in Teams Toolkit and Office Applications (Word, Exce, Powerpoint, Outlook).
- From Visual Studio Code only: use the `Run and Debug Activity Panel` in Visual Studio Code, select `Debug in Outlook Desktop (Edge Chromium)`, and click the `Run and Debug` green arrow button. Please run VSCode as administrator if localhost loopback for Microsoft Edge Webview hasn't been enabled. Once enbaled, administrator priviledge is no longer required.
- 
+ 
Once the Outlook app is open, select a mailbox item, and you can then use the Outlook add-in. For example, you can select the option to show a task pane.

@@ -56,6 +56,8 @@ Now you have the ability to create a single unit of distribution for all your Mi
The taskpane should look as shown in the following image.

+ Other Office Applications share the same behavior.
+
### Edit the manifest
You can find the app manifest in `./appPackage` folder. The folder contains one manifest file:
@@ -86,9 +88,9 @@ Once the provisioning and deployment steps are finished, you can preview your Te
- From Teams Toolkit CLI: execute `teamsapp preview --env dev` in your project directory to launch your application.
-### Preview Outlook add-in
+### Preview Office add-in
-Once the provisioning and deployment steps are finished, you can preview your Outlook add-in from Visual Studio Code:
+Once the provisioning and deployment steps are finished, you can preview your Office add-in from Visual Studio Code:
1. Copy the production URL from the `TAB_ENDPOINT` in env/.env.dev file.
2. Edit webpack.config.js file and change urlProd to the value you just copied. Please note to add a '/' at the end of the URL.
@@ -116,6 +118,7 @@ To check that your manifest file is valid:
|April 11, 2023 | yufuwang | comment out manifest validation |
|May 24, 2023 | yefuwang | update outdated content |
|September 10, 2023 | joshuapa | added images |
+|Nov 29, 2024 | hermanwen | replace outlook with office capability |
## Feedback
diff --git a/hello-world-teams-tab-and-outlook-add-in/add-in/.eslintrc.json b/hello-world-teams-tab-and-office-add-in/add-in/.eslintrc.json
similarity index 100%
rename from hello-world-teams-tab-and-outlook-add-in/add-in/.eslintrc.json
rename to hello-world-teams-tab-and-office-add-in/add-in/.eslintrc.json
diff --git a/hello-world-teams-tab-and-outlook-add-in/add-in/assets/icon-128.png b/hello-world-teams-tab-and-office-add-in/add-in/assets/icon-128.png
similarity index 100%
rename from hello-world-teams-tab-and-outlook-add-in/add-in/assets/icon-128.png
rename to hello-world-teams-tab-and-office-add-in/add-in/assets/icon-128.png
diff --git a/hello-world-teams-tab-and-outlook-add-in/add-in/assets/icon-16.png b/hello-world-teams-tab-and-office-add-in/add-in/assets/icon-16.png
similarity index 100%
rename from hello-world-teams-tab-and-outlook-add-in/add-in/assets/icon-16.png
rename to hello-world-teams-tab-and-office-add-in/add-in/assets/icon-16.png
diff --git a/hello-world-teams-tab-and-outlook-add-in/add-in/assets/icon-32.png b/hello-world-teams-tab-and-office-add-in/add-in/assets/icon-32.png
similarity index 100%
rename from hello-world-teams-tab-and-outlook-add-in/add-in/assets/icon-32.png
rename to hello-world-teams-tab-and-office-add-in/add-in/assets/icon-32.png
diff --git a/hello-world-teams-tab-and-outlook-add-in/add-in/assets/icon-64.png b/hello-world-teams-tab-and-office-add-in/add-in/assets/icon-64.png
similarity index 100%
rename from hello-world-teams-tab-and-outlook-add-in/add-in/assets/icon-64.png
rename to hello-world-teams-tab-and-office-add-in/add-in/assets/icon-64.png
diff --git a/hello-world-teams-tab-and-outlook-add-in/add-in/assets/icon-80.png b/hello-world-teams-tab-and-office-add-in/add-in/assets/icon-80.png
similarity index 100%
rename from hello-world-teams-tab-and-outlook-add-in/add-in/assets/icon-80.png
rename to hello-world-teams-tab-and-office-add-in/add-in/assets/icon-80.png
diff --git a/hello-world-teams-tab-and-outlook-add-in/add-in/assets/logo-filled.png b/hello-world-teams-tab-and-office-add-in/add-in/assets/logo-filled.png
similarity index 100%
rename from hello-world-teams-tab-and-outlook-add-in/add-in/assets/logo-filled.png
rename to hello-world-teams-tab-and-office-add-in/add-in/assets/logo-filled.png
diff --git a/hello-world-teams-tab-and-outlook-add-in/add-in/babel.config.json b/hello-world-teams-tab-and-office-add-in/add-in/babel.config.json
similarity index 100%
rename from hello-world-teams-tab-and-outlook-add-in/add-in/babel.config.json
rename to hello-world-teams-tab-and-office-add-in/add-in/babel.config.json
diff --git a/hello-world-teams-tab-and-office-add-in/add-in/package.json b/hello-world-teams-tab-and-office-add-in/add-in/package.json
new file mode 100644
index 000000000..18d7013a1
--- /dev/null
+++ b/hello-world-teams-tab-and-office-add-in/add-in/package.json
@@ -0,0 +1,69 @@
+{
+ "name": "office-addin-taskpane",
+ "version": "0.0.1",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/OfficeDev/Office-Addin-TaskPane.git"
+ },
+ "license": "MIT",
+ "config": {
+ "app_to_debug": "excel",
+ "app_type_to_debug": "desktop",
+ "dev_server_port": 53000
+ },
+ "scripts": {
+ "build": "webpack --mode production",
+ "build:dev": "webpack --mode development",
+ "dev-server": "webpack serve --mode development",
+ "lint": "office-addin-lint check",
+ "lint:fix": "office-addin-lint fix",
+ "prettier": "office-addin-lint prettier",
+ "signin": "office-addin-dev-settings m365-account login",
+ "signout": "office-addin-dev-settings m365-account logout",
+ "start": "office-addin-debugging start ../appPackage/build/appPackage.local.zip",
+ "start:desktop": "office-addin-debugging start ../appPackage/build/appPackage.local.zip desktop",
+ "start:desktop:word": "office-addin-debugging start ../appPackage/build/appPackage.local.zip --app word",
+ "start:desktop:excel": "office-addin-debugging start ../appPackage/build/appPackage.local.zip --app excel",
+ "start:desktop:powerpoint": "office-addin-debugging start ../appPackage/build/appPackage.local.zip --app powerpoint",
+ "start:desktop:outlook": "office-addin-debugging start ../appPackage/build/appPackage.local.zip --app outlook",
+ "start:web": "office-addin-debugging start ../appPackage/build/appPackage.local.zip web",
+ "stop": "office-addin-debugging stop ../appPackage/build/manifest.local.json",
+ "validate": "office-addin-manifest validate ../appPackage/build/manifest.local.json",
+ "watch": "webpack --mode development --watch"
+ },
+ "dependencies": {
+ "core-js": "^3.36.0",
+ "regenerator-runtime": "^0.14.1"
+ },
+ "devDependencies": {
+ "@babel/core": "^7.24.0",
+ "@babel/preset-typescript": "^7.23.3",
+ "@types/office-js": "^1.0.377",
+ "@types/office-runtime": "^1.0.35",
+ "babel-loader": "^9.1.3",
+ "copy-webpack-plugin": "^12.0.2",
+ "eslint-plugin-office-addins": "^3.0.2",
+ "file-loader": "^6.2.0",
+ "html-loader": "^5.0.0",
+ "html-webpack-plugin": "^5.6.0",
+ "office-addin-cli": "^1.6.3",
+ "office-addin-debugging": "^5.1.4",
+ "office-addin-dev-certs": "^1.13.3",
+ "office-addin-lint": "^2.3.3",
+ "office-addin-manifest": "^1.13.4",
+ "office-addin-prettier-config": "^1.2.1",
+ "os-browserify": "^0.3.0",
+ "process": "^0.11.10",
+ "source-map-loader": "^5.0.0",
+ "ts-loader": "^9.5.1",
+ "typescript": "^5.4.2",
+ "webpack": "^5.90.3",
+ "webpack-cli": "^5.1.4",
+ "webpack-dev-server": "5.0.3"
+ },
+ "prettier": "office-addin-prettier-config",
+ "browserslist": [
+ "last 2 versions",
+ "ie 11"
+ ]
+}
\ No newline at end of file
diff --git a/hello-world-teams-tab-and-outlook-add-in/add-in/src/commands/commands.html b/hello-world-teams-tab-and-office-add-in/add-in/src/commands/commands.html
similarity index 100%
rename from hello-world-teams-tab-and-outlook-add-in/add-in/src/commands/commands.html
rename to hello-world-teams-tab-and-office-add-in/add-in/src/commands/commands.html
diff --git a/hello-world-teams-tab-and-office-add-in/add-in/src/commands/commands.ts b/hello-world-teams-tab-and-office-add-in/add-in/src/commands/commands.ts
new file mode 100644
index 000000000..5845a7156
--- /dev/null
+++ b/hello-world-teams-tab-and-office-add-in/add-in/src/commands/commands.ts
@@ -0,0 +1,27 @@
+import { insertBlueParagraphInWord } from "./word";
+import { setRangeColorInExcel } from "./excel";
+import { insertTextInPowerPoint } from "./powerpoint";
+import { setNotificationInOutlook } from "./outlook";
+
+/* global Office */
+
+// Register the add-in commands with the Office host application.
+Office.onReady(async (info) => {
+ switch (info.host) {
+ case Office.HostType.Word:
+ Office.actions.associate("action", insertBlueParagraphInWord);
+ break;
+ case Office.HostType.Excel:
+ Office.actions.associate("action", setRangeColorInExcel);
+ break;
+ case Office.HostType.PowerPoint:
+ Office.actions.associate("action", insertTextInPowerPoint);
+ break;
+ case Office.HostType.Outlook:
+ Office.actions.associate("action", setNotificationInOutlook);
+ break;
+ default: {
+ throw new Error(`${info.host} not supported.`);
+ }
+ }
+});
diff --git a/hello-world-teams-tab-and-office-add-in/add-in/src/commands/excel.ts b/hello-world-teams-tab-and-office-add-in/add-in/src/commands/excel.ts
new file mode 100644
index 000000000..a8fcd2281
--- /dev/null
+++ b/hello-world-teams-tab-and-office-add-in/add-in/src/commands/excel.ts
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
+ * See LICENSE in the project root for license information.
+ */
+
+/* global Office Excel console */
+
+/**
+ * Set range color to selected range in excel when the add-in command is executed.
+ * @param event
+ */
+export async function setRangeColorInExcel(event: Office.AddinCommands.Event) {
+ try {
+ await Excel.run(async (context) => {
+ const range = context.workbook.getSelectedRange();
+ range.format.fill.color = "yellow";
+ await context.sync();
+ });
+ } catch (error) {
+ // Note: In a production add-in, notify the user through your add-in's UI.
+ console.error(error);
+ }
+
+ // Be sure to indicate when the add-in command function is complete
+ event.completed();
+}
diff --git a/hello-world-teams-tab-and-outlook-add-in/add-in/src/commands/commands.ts b/hello-world-teams-tab-and-office-add-in/add-in/src/commands/outlook.ts
similarity index 50%
rename from hello-world-teams-tab-and-outlook-add-in/add-in/src/commands/commands.ts
rename to hello-world-teams-tab-and-office-add-in/add-in/src/commands/outlook.ts
index 7149de7c7..9d65fd949 100644
--- a/hello-world-teams-tab-and-outlook-add-in/add-in/src/commands/commands.ts
+++ b/hello-world-teams-tab-and-office-add-in/add-in/src/commands/outlook.ts
@@ -3,17 +3,13 @@
* See LICENSE in the project root for license information.
*/
-/* global global, Office, self, window */
-
-Office.onReady(() => {
- // If needed, Office.js is ready to be called
-});
+/* global Office */
/**
- * Shows a notification when the add-in command is executed.
+ * Show an outlook notification when the add-in command is executed.
* @param event
*/
-function action(event: Office.AddinCommands.Event) {
+export function setNotificationInOutlook(event: Office.AddinCommands.Event) {
const message: Office.NotificationMessageDetails = {
type: Office.MailboxEnums.ItemNotificationMessageType.InformationalMessage,
message: "Performed action.",
@@ -21,24 +17,9 @@ function action(event: Office.AddinCommands.Event) {
persistent: true,
};
- // Show a notification message
+ // Show a notification message.
Office.context.mailbox.item.notificationMessages.replaceAsync("ActionPerformanceNotification", message);
- // Be sure to indicate when the add-in command function is complete
+ // Be sure to indicate when the add-in command function is complete.
event.completed();
}
-
-function getGlobal() {
- return typeof self !== "undefined"
- ? self
- : typeof window !== "undefined"
- ? window
- : typeof global !== "undefined"
- ? global
- : undefined;
-}
-
-const g = getGlobal() as any;
-
-// The add-in command functions need to be available in global scope
-g.action = action;
diff --git a/hello-world-teams-tab-and-office-add-in/add-in/src/commands/powerpoint.ts b/hello-world-teams-tab-and-office-add-in/add-in/src/commands/powerpoint.ts
new file mode 100644
index 000000000..df08cf003
--- /dev/null
+++ b/hello-world-teams-tab-and-office-add-in/add-in/src/commands/powerpoint.ts
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
+ * See LICENSE in the project root for license information.
+ */
+
+/* global Office PowerPoint console */
+
+/**
+ * Shows a notification when the add-in command is executed.
+ * @param event
+ */
+export async function insertTextInPowerPoint(event: Office.AddinCommands.Event) {
+ try {
+ await PowerPoint.run(async (context) => {
+ const slide = context.presentation.getSelectedSlides().getItemAt(0);
+ const textBox = slide.shapes.addTextBox("Hello World");
+ textBox.fill.setSolidColor("white");
+ textBox.lineFormat.color = "black";
+ textBox.lineFormat.weight = 1;
+ textBox.lineFormat.dashStyle = PowerPoint.ShapeLineDashStyle.solid;
+ await context.sync();
+ });
+ } catch (error) {
+ console.log("Error: " + error);
+ }
+
+ // Be sure to indicate when the add-in command function is complete
+ event.completed();
+}
diff --git a/hello-world-teams-tab-and-office-add-in/add-in/src/commands/word.ts b/hello-world-teams-tab-and-office-add-in/add-in/src/commands/word.ts
new file mode 100644
index 000000000..a1504ff60
--- /dev/null
+++ b/hello-world-teams-tab-and-office-add-in/add-in/src/commands/word.ts
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
+ * See LICENSE in the project root for license information.
+ */
+
+/* global Office Word console */
+
+/**
+ * Insert a blue paragraph in word when the add-in command is executed.
+ * @param event
+ */
+export async function insertBlueParagraphInWord(event: Office.AddinCommands.Event) {
+ try {
+ await Word.run(async (context) => {
+ const paragraph = context.document.body.insertParagraph("Hello World", Word.InsertLocation.end);
+ paragraph.font.color = "blue";
+ await context.sync();
+ });
+ } catch (error) {
+ // Note: In a production add-in, notify the user through your add-in's UI.
+ console.error(error);
+ }
+
+ // Be sure to indicate when the add-in command function is complete
+ event.completed();
+}
diff --git a/hello-world-teams-tab-and-office-add-in/add-in/src/taskpane/excel.ts b/hello-world-teams-tab-and-office-add-in/add-in/src/taskpane/excel.ts
new file mode 100644
index 000000000..83c4ee627
--- /dev/null
+++ b/hello-world-teams-tab-and-office-add-in/add-in/src/taskpane/excel.ts
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
+ * See LICENSE in the project root for license information.
+ */
+
+/* global console, document, Excel, Office */
+
+Office.onReady((info) => {
+ if (info.host === Office.HostType.Excel) {
+ document.getElementById("sideload-msg").style.display = "none";
+ document.getElementById("app-body").style.display = "flex";
+ document.getElementById("run").onclick = runExcel;
+ }
+});
+
+export async function runExcel() {
+ try {
+ await Excel.run(async (context) => {
+ /**
+ * Insert your Excel code here
+ */
+ const range = context.workbook.getSelectedRange();
+
+ // Read the range address
+ range.load("address");
+
+ // Update the fill color
+ range.format.fill.color = "yellow";
+
+ await context.sync();
+ console.log(`The range address was ${range.address}.`);
+ });
+ } catch (error) {
+ console.error(error);
+ }
+}
diff --git a/hello-world-teams-tab-and-outlook-add-in/add-in/src/taskpane/taskpane.ts b/hello-world-teams-tab-and-office-add-in/add-in/src/taskpane/outlook.ts
similarity index 52%
rename from hello-world-teams-tab-and-outlook-add-in/add-in/src/taskpane/taskpane.ts
rename to hello-world-teams-tab-and-office-add-in/add-in/src/taskpane/outlook.ts
index f6d014aab..cb0c3d699 100644
--- a/hello-world-teams-tab-and-outlook-add-in/add-in/src/taskpane/taskpane.ts
+++ b/hello-world-teams-tab-and-office-add-in/add-in/src/taskpane/outlook.ts
@@ -9,15 +9,20 @@ Office.onReady((info) => {
if (info.host === Office.HostType.Outlook) {
document.getElementById("sideload-msg").style.display = "none";
document.getElementById("app-body").style.display = "flex";
- document.getElementById("run").onclick = run;
+ document.getElementById("run").onclick = runOutlook;
}
});
-export async function run() {
+export async function runOutlook() {
/**
* Insert your Outlook code here
*/
const item = Office.context.mailbox.item;
- document.getElementById("item-subject").innerHTML = "Subject:
" + item.subject;
+ let insertAt = document.getElementById("item-subject");
+ let label = document.createElement("b").appendChild(document.createTextNode("Subject: "));
+ insertAt.appendChild(label);
+ insertAt.appendChild(document.createElement("br"));
+ insertAt.appendChild(document.createTextNode(item.subject));
+ insertAt.appendChild(document.createElement("br"));
}
diff --git a/hello-world-teams-tab-and-office-add-in/add-in/src/taskpane/powerpoint.ts b/hello-world-teams-tab-and-office-add-in/add-in/src/taskpane/powerpoint.ts
new file mode 100644
index 000000000..84185b978
--- /dev/null
+++ b/hello-world-teams-tab-and-office-add-in/add-in/src/taskpane/powerpoint.ts
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
+ * See LICENSE in the project root for license information.
+ */
+
+/* global document, Office */
+
+Office.onReady((info) => {
+ if (info.host === Office.HostType.PowerPoint) {
+ document.getElementById("sideload-msg").style.display = "none";
+ document.getElementById("app-body").style.display = "flex";
+ document.getElementById("run").onclick = runPowerPoint;
+ }
+});
+
+export async function runPowerPoint() {
+ /**
+ * Insert your PowerPoint code here
+ */
+ const options: Office.SetSelectedDataOptions = { coercionType: Office.CoercionType.Text };
+
+ await Office.context.document.setSelectedDataAsync(" ", options);
+ await Office.context.document.setSelectedDataAsync("Hello World!", options);
+}
diff --git a/hello-world-teams-tab-and-outlook-add-in/add-in/src/taskpane/taskpane.css b/hello-world-teams-tab-and-office-add-in/add-in/src/taskpane/taskpane.css
similarity index 100%
rename from hello-world-teams-tab-and-outlook-add-in/add-in/src/taskpane/taskpane.css
rename to hello-world-teams-tab-and-office-add-in/add-in/src/taskpane/taskpane.css
diff --git a/hello-world-teams-tab-and-outlook-add-in/add-in/src/taskpane/taskpane.html b/hello-world-teams-tab-and-office-add-in/add-in/src/taskpane/taskpane.html
similarity index 91%
rename from hello-world-teams-tab-and-outlook-add-in/add-in/src/taskpane/taskpane.html
rename to hello-world-teams-tab-and-office-add-in/add-in/src/taskpane/taskpane.html
index 9e5fb7010..54fbf7efa 100644
--- a/hello-world-teams-tab-and-outlook-add-in/add-in/src/taskpane/taskpane.html
+++ b/hello-world-teams-tab-and-office-add-in/add-in/src/taskpane/taskpane.html
@@ -26,7 +26,7 @@