Home > .Net, Miscellaneous, Office Interoperability > Calling word Macros from .Net

Calling word Macros from .Net

September 20th, 2007 Anuraj P Leave a comment Go to comments

While using Word automation with .Net sometimes it is required ti call, word macro’s from C# or VB.Net.

Here is the code to call word macros from VB.Net.

Dim WordApp As New Microsoft.Office.Interop.Word.Application
CType(WordApp, Object).GetType().InvokeMember("Run", Reflection.BindingFlags.Default Or Reflection.BindingFlags.InvokeMethod, Nothing, CType(WordApp, Object), New Object() {"helloworld"})

In the code, helloworld is the macro name.Or you can simply call WordApp.Run("helloworld") will also works fine.

 

You can also refer link from Microsoft
http://support.microsoft.com/kb/306683

  1. No comments yet.
  1. No trackbacks yet.