C++ namespace for Excel application

  • Thread starter Thread starter bill
  • Start date Start date
B

bill

All,

I cannot find any examples of doing Excel automation from a VC++ .Net
environment. Does anyone ay least know what the namespace should be to
expose the Excel app? i.e.

using namespace System::?????????????????

TIA,

Bill
 
bill said:
All,

I cannot find any examples of doing Excel automation from a VC++ .Net
environment. Does anyone ay least know what the namespace should be to
expose the Excel app? i.e.

using namespace System::?????????????????

Are you doing managed C++ or native (aka unmanaged) C++?

For managed, you use the same manage PIAs (Primary Interop Assemblies) and
namespaces as you would for C# or VB.NET.

For unmanaged, you program Excell through it's OLE Automation (aka COM)
interface. Your best bet to get started is to look up the #import compiler
directive, and then try

#import "progid:Excel.Sheet"

The #import directive will create C++ wrappers that allow you to call the
OLE interfaces as comfortably as you could from VB6. The declarations will
be (by default) placed in a namespace with the same name as the library.

IIRC, you may also need to #import one or more common MS Office type
libraries (e.g. MSGraph.Application) in order to have full access to the
Excel API.

-cd
 
I am doing managed C++. I cannot seem to get the reference to the Excel
"object". I have the following references:

Excel
Microsoft.Office.Core

I cannot seem to figure out how to declare an Excel app from C++. I
also notice that intellisense works with all the references except for
Excel. Any pointers to examples that you can share. I have been
googling around in my spare time but cannot find anything useful (so
far).

TIA,

Bill
 
bill said:
I am doing managed C++. I cannot seem to get the reference to the
Excel "object". I have the following references:

Excel
Microsoft.Office.Core

I cannot seem to figure out how to declare an Excel app from C++. I
also notice that intellisense works with all the references except for
Excel. Any pointers to examples that you can share. I have been
googling around in my spare time but cannot find anything useful (so
far).

I have no experience controlling Excel from managed C++ (or any managed
language, for that matter). You might try posting in

microsoft.public.dotnet.framework.interop

and/or the VSTO group where you probably have a better chance of finding
someone that's been down your particular road before.

-cd
 
Back
Top