开发者

Unable to run the specified macro

This is the sample code

wrdApp.Run("Macro1", ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
   ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
  开发者_运维问答 ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
   ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

When I am trying to run the application, @ the above line it is throwing the following error.

COM Exception: Unable to run the specified macro.

I am reading a template and then performing some operations.

Please help me

Regards

Sarayu


Found it!

This drive me crazy for days. Here's the deal - You're calling

wrdApp.Run(.... 

on the WordApp object however the macro is (probably) executing against a Document. Word needs to know the ActiveDocument in order to execute. So before calling wrdApp.Run() add the following line:

wrdDoc.Activate()

This solved my problem

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜