开发者

Run Word VBA with msgbox via C# without user interaction

I am running a macro in a Word document via C#, the macro basically creates a copy of the document and adds a couple of more attributes.

But the issue is that, my macro has a confirmation msgbox at some point of the code which needs user interaction.

I am using the code below grabbed from MS's web site. So the question is;

Is there any way to suppress or auto-confirm the messagebox shown on the run of macro?

private void RunMacro开发者_StackOverflow社区(object oApp, object[] oRunArgs)
{
    oApp.GetType().InvokeMember("Run",
        System.Reflection.BindingFlags.Default |
        System.Reflection.BindingFlags.InvokeMethod,
        null, oApp, oRunArgs);
}


Since it is your macro, just change it so it does not show the confirmation msgbox.

When you need the macro in another context where the confirmation msgbox shall appear, add a boolean flag useConfirmationMsgBox as Boolean to your macro code, and show the MsgBox only when this flag is true. Then, provide two different entry points, one where useConfirmationMsgBox is set to true, and one where it is set to false.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜