开发者

Create new Word document with macro in C#

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.

How do I 开发者_JS百科create a new document with the macro from another document?


It's been months since this question has had a formal answer, so for the record, on Apr 5th 2011, bruggesboy spake thusly:

Fixed it, this is the solution:

    //create new document, location = path to template
    Document doc = Globals.ThisAddIn.Application.Documents.Add(location);
    //auto run macro 
    doc.RunAutoMacro(WdAutoMacros.wdAutoOpen);

And behold, there were word documents with macro's running about.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜