HighTechTalks DotNet Forums  

New Wprd.Application failing with "This command is not available because no document is open"

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss New Wprd.Application failing with "This command is not available because no document is open" in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
mdupris@hotmail.com
 
Posts: n/a

Default New Wprd.Application failing with "This command is not available because no document is open" - 06-28-2007 , 02:39 PM






I can't open a Word session in a C# session without getting an error
"This command is not available because no document is open". The
simplest code illustrating the problem is below:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Word = Microsoft.Office.Interop.Word;

namespace JustOpenWord
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Word.Application oWord = new Word.Application();
}
}
}

The error occurs on execution of the "Word.Application oWord = new
Word.Application();" line.

The same failure occurs with variants such as "ApplicationClass" or
"_Application". I've tried using "try/catch" to manage the error, and
the pop-up, without success. Suspecting an Office configuration issue
(Office 2003 running in Windows XP) I re-installed Office, without
success.

Anyone have any clues what's going on here? They would be greatly
appreciated.

= M =


Reply With Quote
  #2  
Old   
mdupris@hotmail.com
 
Posts: n/a

Default Re: New Wprd.Application failing with "This command is not available because no document is open" - 06-29-2007 , 12:44 PM







Never mind... Seems an old COM Add-in had inserted itself into the
system and was fouling things up. (Loud "Duh!" sound at this end, when
it was discovered).

= M =

On Jun 28, 11:39 am, mdup... (AT) hotmail (DOT) com wrote:
Quote:
I can't open a Word session in a C# session without getting an error
"This command is not available because no document is open". The
simplest code illustrating the problem is below:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Word = Microsoft.Office.Interop.Word;

namespace JustOpenWord
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
Word.Application oWord = new Word.Application();
}
}

}

The error occurs on execution of the "Word.Application oWord = new
Word.Application();" line.

The same failure occurs with variants such as "ApplicationClass" or
"_Application". I've tried using "try/catch" to manage the error, and
the pop-up, without success. Suspecting an Office configuration issue
(Office 2003 running in Windows XP) I re-installed Office, without
success.

Anyone have any clues what's going on here? They would be greatly
appreciated.

= M =



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.