开发者

Running a macro from an external application and using and xml document as datasource in word

I have an application which should generate some reports-like files in word. Right now the full report is written by the application itself using the word API but we are thinking on leaving all the report construction logic in the word document itself as a Macro.

To do so, I need to know how to run a macro from the external location. Also, the contents of the macro are either in an XML file, although it would be easier if I can just send it an xml-com开发者_JS百科 object node.

I've been googling for a while without finding exactly this questions.

P.S. The solution should work for all versions of word from 2003 to 2010


You can put the code in or call the code from the Document_Open() or Document_New() event handlers.


Depending on how intense the code required to generate the doc is, you could also build a Word Add in, then expose functionality in it via the COMAddins.Object property (in Word).

That gives external processes direct access to functions in a compiled Word Addin. At that point, you could pass whatever you want to the internal code, plus it's all early bound and in process, which makes Word Object model manipulation a WHOLE lot faster.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜