简体   繁体   English

在 word 365 中,我在哪里可以找到将它们放置在页面上的模板变量?

[英]In word 365 where can I find the template variables to place them on the page?

We have an existing legacy system where I'm able to download existing templates, update them and save them as documents with my edits.我们有一个现有的遗留系统,我可以在其中下载现有模板、更新它们并将它们保存为带有我编辑的文档。 Here is a portion of the code.这是代码的一部分。

#region Open existing Template and write something to it.
    object missing = Type.Missing;
    Word.Application app = new Word.Application();
    Word.Document doc = app.Documents.Open(@"C:\\test395310.dot", ref missing, true);
    doc.Activate();                                                    
    doc.Variables["CASE PLAN_PLAN_STATUS"].Value = "asdf1";
    doc.Variables["CASE PLAN_PROGRAM"].Value = "asdf2";
    doc.Fields.Update();
#endregion

Using similar logic I'm attempting to create a new word template with 2 variables.使用类似的逻辑,我试图创建一个带有 2 个变量的新单词模板。

private static void CreateTemplate()
    {
        //have it open word and create a template with fields from gen
        object missing = Type.Missing;
        Word.Application app = new Word.Application();
        Word.Document doc = app.Documents.Add(ref missing, ref missing, true);
        doc.Activate();
        doc.Variables.Add("CASE PLAN_PLAN_STATUS", "XXXXX");
        doc.Variables.Add("ANOTHER ONE", "XXXX");
        doc.Fields.Update();
        doc.SaveAs2(@"C:\\newTemplate.dot");
        doc.Close();
        app.Quit();
    }

The document is getting created, however in word I cannot find either variable.正在创建文档,但是在 word 中我找不到任何一个变量。 My goal is to open word and placement in the template with formatting.我的目标是使用格式打开模板中的单词和位置。 ie IE

Plan Status: <<CASE PLAN_PLAN_STATUS>>

If I click insert/Explore Quick Parts/field, I can see various options, but my two variables aren't there.如果我单击插入/探索快速部件/字段,我可以看到各种选项,但我的两个变量不存在。 Anyone know where else to look?有谁知道还有什么地方可以看? Or a better approach?还是更好的方法?

Within your template, you can use DocVariable fields.在您的模板中,您可以使用 DocVariable 字段。

https://support.microsoft.com/en-us/office/field-codes-docvariable-field-32a81e22-c5c1-4b16-8097-f0de851db67c?ui=en-US&rs=en-US&ad=US It would look like { DocVariable Case_Plan_Plan_Status } with field codes revealed. https://support.microsoft.com/en-us/office/field-codes-docvariable-field-32a81e22-c5c1-4b16-8097-f0de851db67c?ui=en-US&rs=en-US&ad=US它看起来像{ DocVariable Case_Plan_Plan_Status } 显示域代码。

Unlike Document Properties, Document Variables can only be created, modified, or deleted using vba.与文档属性不同,文档变量只能使用 vba 创建、修改或删除。

There are no built-in Document Variables.没有内置的文档变量。 There is no tool built into the user interface for seeing what is available among variables.用户界面中没有内置工具来查看变量中可用的内容。

I do know of several good Add-Ins for manipulating them in the user interface.我确实知道一些用于在用户界面中操作它们的好插件。

One is Chris Woodman's old Keyboard Shortcut Organizer.一个是 Chris Woodman 的旧键盘快捷键管理器。 http://addbalance.com/word/download.htm#ChrisWoodman This one lets you view, create, edit and delete variables from within Word but does not create a DocVariable field, leaving that for you to do. http://addbalance.com/word/download.htm#ChrisWoodman此选项可让您在 Word 中查看、创建、编辑和删除变量,但不会创建 DocVariable 字段,让您自行处理。

Another is Graham Mayor's or Greg Maxey's utility.另一个是 Graham Mayor 或 Greg Maxey 的实用程序。 http://gregmaxey.com/word_tip_pages/cc_var_bm_doc_prop_tools_addin.html or http://www.gmayor.com/BookmarkandVariableEditor.htm Both of these last two can add a DocVariable Field to your document after you select the variable from a list. http://gregmaxey.com/word_tip_pages/cc_var_bm_doc_prop_tools_addin.html or http://www.gmayor.com/BookmarkandVariableEditor.htm Both of these last two can add a DocVariable Field to your document after you select the variable from a list.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 OpenXML 在 Word 文档中查找变量并替换它们 - OpenXML Find Variables within Word doc and replace them 如何在ms字模板中放置标签并用数据库中的数据填充它们 - How to place labels in a ms word template and fill them with data from database 您知道在哪里可以找到NConsoler的文档吗? - Do you know any place where I can find documentation for NConsoler? '&lt;&gt;c.&lt;&gt;9' 是什么意思?我找不到它们的任何声明,它们来自哪里? - What's meaning of '<>c.<>9'?I can't find any declaration of them,where are they from? 在哪里可以找到 Microsoft.Office.Interop.Word.dll (2010)? - Where can I find Microsoft.Office.Interop.Word.dll (2010)? MS Word Automation-查找表所在的页码 - MS Word Automation - find the page number where a table is located 我在哪里可以找到可以从存储过程创建文件(Excel、txt、csv)的模板 SSIS 包 - Where can I find template SSIS package that would create file ( Excel, txt, csv) from stored procedure 在哪里可以找到 ServiceAccountCredential - where can i find ServiceAccountCredential 在哪里可以找到CSharpEvaluator? - Where can I find CSharpEvaluator? 在字符串中查找单词,其中字符串可以为null(有时) - Find a word in a string where the string can be null (sometimes)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM