Archived

This topic is now archived and is closed to further replies.

MButchers

c# Builder + Word 2000

Recommended Posts

MButchers    123
Hello all, Im trying to use Word 2000 from a windows forms application developed in c# builder however I cannot access the word object im doing the following

private void button1_Click(object sender, System.EventArgs e)
{
    //Word.ApplicationClass wrd = new Word.ApplicationClass();

    //wrd.Visible = true;


    Word._Application wrd = new Word.Application();
    wrd.Visible = true;
}

neither of the above work, both routes compile ok however when I call wrd.Visible = true; I get the following error Project Test.exe encountered unhandled exception class system.invalidcastexception Anyone have any ideas? Thanks in advance Mark

Share this post


Link to post
Share on other sites
Arild Fines    968
Try declaring wrd as Word.Application, not Word._Application. There is a complete example of Word interop in the samples subdir of the .NET SDK(Even BC#B should install this). On my machine this sample can be found in \Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Samples\Technologies\Interop\Applications\Office\Word. If BC#B installed the SDK for you, it might be somewhere else.

--
AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.
[Project site] [Blog] [RSS] [Browse the source] [IRC channel]

Share this post


Link to post
Share on other sites
MButchers    123
Cheers for the reply.

Am now doing the following



Word.Application wrd = new Word.Application();

try
{
wrd.Visible = true;
}
catch (Exception ex)
{
Console.Write(ex.Message);
}



the exception thrown is

"QueryInterface for Interface Word._Application failed."

is this down to the fact im using word 2000 not word xp, as
in the readme for the example in the .Net SDK it specifies
that Office XP is required.

Cheers

Mark

Share this post


Link to post
Share on other sites