Calling from C#.Net App Office._CommandBarButton.Execute() method in Excel 2003 throws a COMExceptio

J

Jacek

Hi All!

Currently I host Workbook in WebBrowser control which runs within AXHost
placed on Windows.Form.
When some methods of CommandBarButton are called I got a COMException. It
does
not matter if the Main Menu instance or toolbar instance method is called,
item is always checked to be
Enabled and furthemore for both MsoControlOLEUsage Server and Client the
behaviour is the same.
Some methods, however, work fine: i.e. Copy, CopyFace, Equals, PasteFace -
not working ones are Exceute, Reset.
Furthermore I can not cast .Picutre property to stdole.IPictureDisp
interface - exception is thrown again.

Any ideas for solution?

Jacek
 
J

Jacek

Hi Again!

just forgot to include sample code:

Office.CommandBarControl cbc2 = (Office.CommandBarControl)cbcEnum.Current;
if (cbc2 is Office.CommandBarButton)
{
if (cbc2.Caption == "&Copy")
{
if (cbc2.Enabled = = true)
{
cbc2.Execute() ; /// or .Reset();
}
}
}

Similar problems appear when I call supposedly simple dialog box:

Office.FileDialog fdlg =
this.xlApp.get_FileDialog(Office.MsoFileDialogType.msoFileDialogSaveAs);
fdlg.InitialFileName = this.DocumentName;
if (fdlg.Show() = = -1)
{
fdlg.Execute();
}

Dialog is shown and after selecting file name closes with correct result but
when Execute() method is called exception is thrown!

I work with Office2k3 or XP - result is always this same.

Jacek
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top