[英]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?
还是更好的方法?
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 } 显示域代码。
There are no built-in Document Variables.没有内置的文档变量。 There is no tool built into the user interface for seeing what is available among variables.
用户界面中没有内置工具来查看变量中可用的内容。
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.