vb.net 如何使用VB.Net自动填充word文档

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15295368/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 12:40:43  来源:igfitidea点击:

how to auto fill a word document with VB.Net

asp.netvb.netms-wordms-office

提问by jason

I would like to create a Microsoft Word template that I can have a VB.net project auto fill specific fields in with database values. My question is how to best go about this with Word. Should I create a Template and add Fields, Bookmarks, or something else? I looked at fields but didn't see a way to create custom field names. Ideally, I would like to create a group of templates that have the same "Field" names that my application can recognize and fill in. Any advice would be great.

我想创建一个 Microsoft Word 模板,我可以让 VB.net 项目使用数据库值自动填充特定字段。我的问题是如何最好地使用 Word 来解决这个问题。我应该创建一个模板并添加字段、书签或其他内容吗?我查看了字段,但没有看到创建自定义字段名称的方法。理想情况下,我想创建一组模板,这些模板具有我的应用程序可以识别和填写的相同“字段”名称。任何建议都会很棒。

Thanks

谢谢

回答by Ryan McDonough

I would suggest that you follow the guide on MSDN:

我建议您按照 MSDN 上的指南进行操作:

http://social.msdn.microsoft.com/Forums/en/vbide/thread/1558f560-8ae6-413a-bbc4-aa8d5d912aac

http://social.msdn.microsoft.com/Forums/en/vbide/thread/1558f560-8ae6-413a-bbc4-aa8d5d912aac

Essentially you are going to create a document with placeholders then use VB to open the document and replace those placeholders.

本质上,您将创建一个带有占位符的文档,然后使用 VB 打开该文档并替换这些占位符。