C++ namespace for Excel application

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bill

    #1

    C++ namespace for Excel application

    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

  • Carl Daniel [VC++ MVP]

    #2
    Re: C++ namespace for Excel application

    bill wrote:[color=blue]
    > 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::??????? ??????????[/color]

    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.S heet"

    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.Applica tion) in order to have full access to the
    Excel API.

    -cd


    Comment

    • bill

      #3
      Re: C++ namespace for Excel application

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

      Excel
      Microsoft.Offic e.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

      Comment

      • Carl Daniel [VC++ MVP]

        #4
        Re: C++ namespace for Excel application

        bill wrote:[color=blue]
        > I am doing managed C++. I cannot seem to get the reference to the
        > Excel "object". I have the following references:
        >
        > Excel
        > Microsoft.Offic e.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).[/color]

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

        microsoft.publi c.dotnet.framew ork.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


        Comment

        Working...