471,327 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,327 software developers and data experts.

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.ApplicationClass();
if(WordApp != null)
{
WordApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
WordDoc = WordApp.Documents.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.ActiveWindow.Selection.WholeStory(); // GENERATE ERROR >
NullReferenceException
WordText = WordDoc.ActiveWindow.Selection.Text;
}
}

The ActiveWindow property is null.

Whats wrong in this code?

Thanks :)
Jan 25 '06 #1
1 1651
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]
- mv*@spam.guard.caspershouse.com

"Kevin" <@> wrote in message news:%2****************@TK2MSFTNGP14.phx.gbl...
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.ApplicationClass();
if(WordApp != null)
{
WordApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;
WordDoc = WordApp.Documents.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.ActiveWindow.Selection.WholeStory(); // GENERATE ERROR >
NullReferenceException
WordText = WordDoc.ActiveWindow.Selection.Text;
}
}

The ActiveWindow property is null.

Whats wrong in this code?

Thanks :)

Jan 25 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Elizabeth Harmon | last post: by
10 posts views Thread by John | last post: by
5 posts views Thread by Cedric | last post: by
8 posts views Thread by gazza67 | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.