在C#中使用宏创建新的Word文档 [英] Create new Word document with macro in C#

查看:222
本文介绍了在C#中使用宏创建新的Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这种情况:

我在Visual Studio 2010(C#)中为Word 2010创建了一个外接程序,该外接程序动态地将新按钮添加到新的功能区选项卡(sql数据库中的数据).现在,当我单击一个按钮时,需要打开一个带有宏的新文档.我在文档(.docm)中具有所需的宏,并且它的路径在数据库中.

我现在的问题是,如何使用另一个文档中的宏创建一个新文档?

谢谢.

I have this situation:

I made an add-in for Word 2010 in visual studio 2010 (C#), which dynamicly adds new buttons to a new ribbon tab (data from sql database). Now when i click on a button, a new document with a macro needs to be opend. I have the needed macro in a document (.docm), and the path to it is in the database.

My problem now is, how do i create a new document with the macro from another document?

thanks.

推荐答案

我认为您不能将宏从另一个文档导入"到另一个文档中.

我可能不在这里,但是您不想在此模板中创建带有宏的Word模板,然后在基于此新模板(通过C#代码)创建新的Word Doc时.
I don''t think you can "import" a macro from another document into a separate document on the fly.

I could be off based here but don''t you want to create a Word Template with the macro in this template and then when you create a new Word Doc (through your C# code) based on this new template.


这篇关于在C#中使用宏创建新的Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆