c# Builder + Word 2000

Started by
1 comment, last by MButchers 20 years, 7 months ago
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
Advertisement
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]
--AnkhSVN - A Visual Studio .NET Addin for the Subversion version control system.[Project site] [IRC channel] [Blog]
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

This topic is closed to new replies.

Advertisement