Skip to content

Instantly share code, notes, and snippets.

@AbidRahman-MSFT
AbidRahman-MSFT / Ooxml footnotes.WORD.yaml
Last active November 18, 2021 14:36
Replace selection with sample text and footnote using Ooxml.
name: Ooxml footnotes
description: Replace selection with sample text and footnote using Ooxml.
host: WORD
api_set: {}
script:
content: >
$("#run").click(() => tryCatch(run));
const prefix = `<?xml version="1.0" encoding="UTF-8"?><pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"><pkg:part pkg:name="/_rels/.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="512"><pkg:xmlData><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml" /></Relationships></pkg:xmlData></pkg:part><pkg:part pkg:name="/word/_rels/document.xml.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="256"><pkg:xmlData><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId4" Type="http://schemas.openxmlform
@AbidRahman-MSFT
AbidRahman-MSFT / Content control basics.WORD.yaml
Created March 1, 2021 23:36
Inserts, updates, and retrieves content controls with HTML.
name: Content control basics
description: 'Inserts, updates, and retrieves content controls.'
host: WORD
api_set: {}
script:
content: |
$("#insert-controls").click(() => tryCatch(insertContentControls));
$("#change-controls").click(() => tryCatch(modifyContentControls));
$("#setup").click(() => tryCatch(setup));
@AbidRahman-MSFT
AbidRahman-MSFT / Get bibliography CXP.WORD.yaml
Created March 6, 2021 01:50
Fetch the xml representation of the bibliography.
name: Get bibliography CXP
description: Fetch the xml representation of the bibliography.
host: WORD
api_set: {}
script:
content: |
$("#run").click(() => tryCatch(run));
async function run() {
await Word.run(async (context) => {
@AbidRahman-MSFT
AbidRahman-MSFT / Search.WORD.yaml
Created March 9, 2021 16:20
Shows basic and advanced search capabilities.
name: Search
description: Shows basic and advanced search capabilities.
host: WORD
api_set: {}
script:
content: |
$("#setup").click(() => tryCatch(setup));
$("#basic-search").click(() => tryCatch(basicSearch));
$("#wildcard-search").click(() => tryCatch(wildcardSearch));
name: Set the left indent of a paragraph (w 1.1 and 1.2 API sets only)
description: ''
host: WORD
api_set: {}
script:
content: |
$("#run").click(() => tryCatch(run));
async function run() {
await Word.run(async (context) => {
name: Print HTML value of document body.
description: ''
host: WORD
api_set: {}
script:
content: |
$("#run").click(() => tryCatch(run));
async function run() {
await Word.run(async (context) => {
@AbidRahman-MSFT
AbidRahman-MSFT / Get File Url.WORD.yaml
Created March 19, 2021 17:52
Get the current file's URL. If unsaved, will return null.
name: Get File Url
description: 'Get the current file''s URL. If unsaved, will return null.'
host: WORD
api_set: {}
script:
content: |
$("#run").click(() => tryCatch(run));
async function run() {
await Word.run(async (context) => {
@AbidRahman-MSFT
AbidRahman-MSFT / Get OOxml of document body.WORD.yaml
Created April 9, 2021 21:29
Logs the ooxml of the document body.
name: Get OOxml of document body
description: Logs the ooxml of the document body.
host: WORD
api_set: {}
script:
content: |
$("#run").click(() => tryCatch(run));
async function run() {
await Word.run(async (context) => {
@AbidRahman-MSFT
AbidRahman-MSFT / Get OOxml text content for selection..WORD.yaml
Created April 21, 2021 23:01
Returns the OOxml text content for the selection (even for hidden field codes).
name: Get OOxml text content for selection.
description: >-
Returns the OOxml text content for the selection (even for hidden field
codes).
host: WORD
api_set: {}
script:
content: |
$("#run").click(() => tryCatch(run));
@AbidRahman-MSFT
AbidRahman-MSFT / Scroll to a range.WORD.yaml
Created May 4, 2021 19:28
Scrolls to a range with and without selection.
name: Scroll to a range
description: Scrolls to a range with and without selection.
host: WORD
api_set: {}
script:
content: |
$("#setup").click(() => tryCatch(setup));
$("#scroll").click(() => tryCatch(scroll));
$("#scroll-end").click(() => tryCatch(scrollEnd));