Rak*_*A R 2 ms-word office-addins word-field word-addins office-js
我想将 JavaScript API 中的合并字段 ( <<xyz>>) 插入到单词表中。但是,我无法找到 Office Word 加载项的 JavaScript API。
<?xml version=\\"1.0\\" standalone=\\"yes\\"?> <?mso-application progid=\\"Word.Document\\"?><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/document.xml\\" pkg:contentType=\\"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\\"><pkg:xmlData><w:document xmlns:w=\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\"><w:body> <w:p w:rsidR=\\"002715FD\\" w:rsidRDefault=\\"002715FD\\"><w:fldSimple w:instr=\\" MERGEFIELD "Last_Name" \\"><w:r><w:rPr><w:noProof /></w:rPr><w:t>\xc2\xabLast_Name\xc2\xbb</w:t></w:r></w:fldSimple></w:p><w:sectPr w:rsidR=\\"00000000\\"> <w:pgSz w:w=\\"12240\\" w:h=\\"15840\\"/><w:pgMar w:top=\\"1440\\" w:right=\\"1440\\" w:bottom=\\"1440\\" w:left=\\"1440\\" w:header=\\"720\\" w:footer=\\"720\\" w:gutter=\\"0\\"/><w:cols w:space=\\"720\\"/></w:sectPr> </w:body> </w:document> </pkg:xmlData></pkg:part></pkg:package> \nRun Code Online (Sandbox Code Playgroud)\n\n上面是合并字段的 xml
\n\nWord.run(function (context) {\n\n // Queue a command to get the current selection and then\n // create a proxy range object with the results.\n var range = context.document.getSelection();\n\n // Queue a commmand to insert OOXML in to the beginning of the range.\n range.insertOoxml("PASTE ABOVE MERGE XML", Word.InsertLocation.start);\n\n // Synchronize the document state by executing the queued commands,\n // and return a promise to indicate task completion.\n return context.sync().then(function () {\n console.log(\'OOXML added to the beginning of the range.\');\n });\n})\n.catch(function (error) {\n console.log(\'Error: \' +JSON.stringify(error));\n if (error instanceof OfficeExtension.Error) {\n console.log(\'Debug info: \' + JSON.stringify(error.debugInfo));\n }\n});\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
1732 次 |
| 最近记录: |