Opening Word 2000 File

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin

    Opening Word 2000 File

    Hi
    I've this code to open a Word 2000, but this generate an error. I reference
    to Microsoft Word 9.0 Object Library.

    WordApp = new Word.Applicatio nClass();
    if(WordApp != null)
    {
    WordApp.Display Alerts = Word.WdAlertLev el.wdAlertsNone ;
    WordDoc = WordApp.Documen ts.Open(ref DocFile, ref FalseParam, ref TrueParam,
    ref FalseParam,
    ref DocPassword, ref NullObject, ref NullObject, ref NullObject, ref
    NullObject,
    ref NullObject,ref NullObject, ref IsVisible);
    if(WordDoc != null)
    {
    WordDoc.ActiveW indow.Selection .WholeStory(); // GENERATE ERROR >
    NullReferenceEx ception
    WordText = WordDoc.ActiveW indow.Selection .Text;
    }
    }

    The ActiveWindow property is null.

    Whats wrong in this code?

    Thanks :)


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Opening Word 2000 File

    Kevin,

    If the app isn't visible at all, then how can any window be active?

    Also, why would you assume there is a selection when you open the file?

    What are you trying to do?


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Kevin" <@> wrote in message news:%232F8MbeI GHA.2696@TK2MSF TNGP14.phx.gbl. ..[color=blue]
    > Hi
    > I've this code to open a Word 2000, but this generate an error. I
    > reference to Microsoft Word 9.0 Object Library.
    >
    > WordApp = new Word.Applicatio nClass();
    > if(WordApp != null)
    > {
    > WordApp.Display Alerts = Word.WdAlertLev el.wdAlertsNone ;
    > WordDoc = WordApp.Documen ts.Open(ref DocFile, ref FalseParam, ref
    > TrueParam, ref FalseParam,
    > ref DocPassword, ref NullObject, ref NullObject, ref NullObject, ref
    > NullObject,
    > ref NullObject,ref NullObject, ref IsVisible);
    > if(WordDoc != null)
    > {
    > WordDoc.ActiveW indow.Selection .WholeStory(); // GENERATE ERROR >
    > NullReferenceEx ception
    > WordText = WordDoc.ActiveW indow.Selection .Text;
    > }
    > }
    >
    > The ActiveWindow property is null.
    >
    > Whats wrong in this code?
    >
    > Thanks :)
    >
    >[/color]


    Comment

    Working...