locked
Word automation from ASP.Net RRS feed

  • Question

  • User1453549677 posted

    I picked up this code snippet from MSDN... it's for Word automation from ASP.Net.

     

    The compiler flags an error on the this.Activate(); line.  - there is no Activate. I think that the snippet is based upon the Word 10 library dll, I have Word 12. Is there a replacement for the Activate method?

     

     

    protected void Button1_Click(object sender, EventArgs e)

    {

     

    Word.
    Application wdapp;

    //Shell Word

    System.Diagnostics.Process.Start(@"C:\Program Files\Microsoft Office\Office12\WINWORD.EXE");

     this.Activate();
     
     

    //This Word and other Office applications register themselves in

    //ROT when their top-level window loses focus. Having a MessageBox

    //forces Word to lose focus and then register itself in the ROT.

    Label1.Text = "Launched Word";

    //Get the reference to Word.Application from the ROT.

    wdapp = (Word.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application");

    //Display the name.

    Label2.Text = wdapp.Name;

    //Release the reference.

    wdapp = null;

    }

    Thursday, April 23, 2009 3:28 PM

Answers

  • User1453549677 posted

    I decided to use Crystal reports instead.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 6, 2009 11:07 AM

All replies

  • User1453549677 posted

    Sorry I left out the this.Activate() line.

    Thursday, April 23, 2009 5:41 PM
  • User1453549677 posted

    I decided to use Crystal reports instead.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 6, 2009 11:07 AM