VC++ .NET 2003 and Office 2000

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Helo All - I am working on a good ol Microsoft Word Control for windows forms. I have the control displayed and it sizes and moves but when I start to try and mess with the command bars It freaks out.

One I can't even access command bars unless I:
namespace Office = Interop::Office;

But the the whole IDE crashes when I:
Office::

I mean the whole thing goes down after adding the second colon.

and If I don't add the:
namespace Office = Interop::Office;

I can't compile becuase it says Office::CommandBars is inaccessable or undefined.

If any more info is needed I can do that but I am seriously getting frustrated with this .net interop stuff.

Any help would be sooo apreciated. Thanks.
 
Here is a little code snippet:

Office::CommandBars * pWCmdBars; // The CommandBars
Word::Document * pWDoc; // The Word document
static Word::ApplicationClass * pWApp; // The Word Application

pWApp = new Word::ApplicationClass; // <- This starts WinWord.exe
pWCmdBars = pWApp->get_CommandBars(); // <- This works
Int32 n = pWCmdBars->get_Count(); // <- This throws an exception

I am absolutly baffled by this exception because when tracing throw the code I can watch pWCmdBars and see that Count = 108.

Go figure but I guess I am one step closer.

Note: I have tried modifying the Command bars both before and after setting the window visible.

Here is a snippet of the Watch:

- pWCmdBars 0x04a8be68 Office.CommandBars

- [Office.CommandBarsClass] 0x04a8be68 Office.CommandBarsClass

System.Object 0x04a8be68 System.Object
ActionControl <undefined value> Office.CommandBarControl
+ ActiveMenuBar 0x00988ed8 Office.CommandBar
AdaptiveMenus false bool
+ Application 0x00988ed8 System.Object
Count 108 __int32
Creator 97307460 __int32
DisplayFonts true bool
DisplayKeysInTooltips false bool
DisplayTooltips true bool
....
LargeButtons false bool
....
Parent <error: an exception of type: 0x00988ed8 occurred> System.Object
TmcGetName <cannot view indexed property> __int32
....
 
OK So I can use:
pWApp->get_ActiveWindow()->get_Panes()->Item(0)->set_FullScreen(true);

to hide the bars (kind of), but I still can't do the supposedly simple:

pWApp->get_CommandBars->Item(x)->set_Enabled(false);

Does any one have some insight here????
 
Back
Top