Skip to content

Instantly share code, notes, and snippets.

View xuruiyao-msft's full-sized avatar

xuruiyao xuruiyao-msft

  • Microsoft
  • Beijing
View GitHub Profile
@xuruiyao-msft
xuruiyao-msft / CCRangeTrack.WORD.yaml
Created June 17, 2022 10:13
Create a new snippet from a blank template.
name: CCRangeTrack
description: Create a new snippet from a blank template.
host: WORD
api_set: {}
script:
content: >
var ccRange;
var insertRange;
@xuruiyao-msft
xuruiyao-msft / Blank snippet.WORD.yaml
Created June 28, 2022 05:45
Create a new snippet from a blank template.
name: Blank snippet
description: Create a new snippet from a blank template.
host: WORD
api_set: {}
script:
content: |
$("#run").click(() => tryCatch(run));
async function run() {
await Word.run(async (context) => {
@xuruiyao-msft
xuruiyao-msft / InsertTableToContentControl (1).WORD.yaml
Created June 29, 2022 03:02
Create a new snippet from a blank template.
name: InsertTableToContentControl (1)
description: Create a new snippet from a blank template.
host: WORD
api_set: {}
script:
content: >
$("#run").click(() => tryCatch(run));
const wordWithTable =
@xuruiyao-msft
xuruiyao-msft / SettingTest.WORD.yaml
Created July 20, 2022 08:50
This sample shows how to get and set the change tracking mode and get the before and after of reviewed text.
name: SettingTest
description: >-
This sample shows how to get and set the change tracking mode and get the
before and after of reviewed text.
host: WORD
api_set: {}
script:
content: "$(\"#run\").click(() => tryCatch(run));\n\nasync function run() {\n await Word.run(async (context) => {\n //\_Queue\_commands\_add\_a\_setting.\n var settings = context.document.settings;\n var startMonth = settings.add(\"startMonth\", { month: \"March\", year: 1998 });\n var address = settings.add(\"country\", \"china\");\n\n //\_Queue\_a\_command\_to\_get\_the\_count\_of\_settings.\n var count = settings.getCount();\n\n //\_Synchronize\_the\_document\_state\_by\_executing\_the\_queued\_commands,\n //\_and\_return\_a\_promise\_to\_indicate\_task\_completion.\n await context.sync();\n console.log(\"current count: \" + count.value);\n\n //\_Queue\_a\_command\_to\_delete\_the\_setting.\n startMonth.delete();\n\n //\_Queue\_a\_command\_to\_get\_the\_new\_count\_of\_settings.\n count
@xuruiyao-msft
xuruiyao-msft / FootEndNote.WORD.yaml
Created August 3, 2022 06:29
Create a new snippet from a blank template.
name: FootEndNote
description: Create a new snippet from a blank template.
host: WORD
api_set: {}
script:
content: |
OfficeExtension.config.extendedErrorLogging = true;
$("#run").click(() => tryCatch(run));
async function run() {
@xuruiyao-msft
xuruiyao-msft / FootEndNote (1).WORD.yaml
Created August 4, 2022 06:12
Create a new snippet from a blank template.
name: FootEndNote (1)
description: Create a new snippet from a blank template.
host: WORD
api_set: {}
script:
content: |
OfficeExtension.config.extendedErrorLogging = true;
$("#run").click(() => tryCatch(run));
$("#getFirst").click(() => tryCatch(getFirst));
$("#items").click(() => tryCatch(items));
@xuruiyao-msft
xuruiyao-msft / FootEndNote (1).WORD.yaml
Created August 29, 2022 13:48
Create a new snippet from a blank template.
name: FootEndNote (1)
description: Create a new snippet from a blank template.
host: WORD
api_set: {}
script:
content: |
OfficeExtension.config.extendedErrorLogging = true;
$("#run").click(() => tryCatch(run));
$("#getFirst").click(() => tryCatch(getFirst));
$("#items").click(() => tryCatch(items));
@xuruiyao-msft
xuruiyao-msft / Blank snippet.EXCEL.yaml
Created September 5, 2022 09:36
Create a new snippet from a blank template.
name: Blank snippet
description: Create a new snippet from a blank template.
host: EXCEL
api_set: {}
script:
content: |
Excel.run(async (context) => {
const range = context.workbook.getSelectedRange();
range.format.fill.color = "red";
});
@xuruiyao-msft
xuruiyao-msft / ContentControl&Save Demo.WORD.yaml
Last active February 16, 2023 01:03
Create a new snippet from a blank template.
name: ContentControl&Save Demo
description: Create a new snippet from a blank template.
host: WORD
api_set: {}
script:
content: >
$("#file").change(getBase64);
$("#insert-doc").click(() => tryCatch(insertDoc));
@xuruiyao-msft
xuruiyao-msft / OfficeAtWorkDemo.WORD.yaml
Created March 2, 2023 17:17
Create a new snippet from a blank template.
name: OfficeAtWorkDemo
description: Create a new snippet from a blank template.
host: WORD
api_set: {}
script:
content: |-
OfficeExtension.config.extendedErrorLogging = true;
$("#file").change(getBase64);
$("#ok").click(() => tryCatch(run));