Passing an Excel COM object to a C++ COM Server 
Author Message
 Passing an Excel COM object to a C++ COM Server

Hi
   I am currently trying to create a COM Server under C++ using ATL. This COM
server will be accessed by Excel and be given Excel Range Objects. So I need to
import the Excel type library in my idl file.
   To be able to import the Excel interfaces I used the OLE/COM object viewer to
open the Excel8.olb file and copied what was displayed in a .idl file. This
worked fine until I tried to build my project : the generated idl file was filled
with errors.
   Due to the amount of corrections needed, I wondered if there was another way
to do this.

Thanks.

Laurent



Tue, 26 Aug 2003 18:06:55 GMT  
 Passing an Excel COM object to a C++ COM Server

Hi
   I am currently trying to create a COM Server under C++ using ATL. This
COM
server will be accessed by Excel and be given Excel Range Objects. So I need
to
import the Excel type library in my idl file.
   To be able to import the Excel interfaces I used the OLE/COM object
viewer to
open the Excel8.olb file and copied what was displayed in a .idl file. This
worked fine until I tried to build my project : the generated idl file was
filled
with errors.
   Due to the amount of corrections needed, I wondered if there was another
way
to do this.

Have a look at '#import'. That should bring in information from Excel's type
library (but I don't know where that is... maybe buried in Excel.exe??).

HTH, Loz.



Tue, 26 Aug 2003 21:49:19 GMT  
 Passing an Excel COM object to a C++ COM Server
Quote:
-----Original Message-----


Hi
   I am currently trying to create a COM Server under C++ using ATL. This
COM
server will be accessed by Excel and be given Excel Range Objects. So I need
to
import the Excel type library in my idl file.
   To be able to import the Excel interfaces I used the OLE/COM object
viewer to
open the Excel8.olb file and copied what was displayed in a .idl file. This
worked fine until I tried to build my project : the generated idl file was
filled
with errors.
   Due to the amount of corrections needed, I wondered if there was another
way
to do this.

Have a look at '#import'. That should bring in information from Excel's type
library (but I don't know where that is... maybe buried in Excel.exe??).

HTH, Loz.

-------------------------------------------------------------------

The #import directive causes the compiler to raise the followinf error :

C:\TEMP\ExcelServer\ExcelServer.idl(9) : error C2773: #import only available in
C++ compiler
midl : command line error MIDL1003 : error returned by the C preprocessor (2)

It seems that the #import clause is not available in an .idl file
.



Tue, 26 Aug 2003 23:23:27 GMT  
 Passing an Excel COM object to a C++ COM Server

Quote:
-----Original Message-----


Hi
   I am currently trying to create a COM Server under C++ using ATL. This
COM
server will be accessed by Excel and be given Excel Range Objects. So I need
to
import the Excel type library in my idl file.
   To be able to import the Excel interfaces I used the OLE/COM object
viewer to
open the Excel8.olb file and copied what was displayed in a .idl file. This
worked fine until I tried to build my project : the generated idl file was
filled
with errors.
   Due to the amount of corrections needed, I wondered if there was another
way
to do this.

Have a look at '#import'. That should bring in information from Excel's type
library (but I don't know where that is... maybe buried in Excel.exe??).

HTH, Loz.

-------------------------------------------------------------------

The #import directive causes the compiler to raise the followinf error :

C:\TEMP\ExcelServer\ExcelServer.idl(9) : error C2773: #import only available
in
C++ compiler
midl : command line error MIDL1003 : error returned by the C preprocessor
(2)

It seems that the #import clause is not available in an .idl file

You are right.... you only use it in C++. Generally, you would put the
statement in your StdAfx.h file so that the generated code is included in
any precompiled header you may be using.

Anyway... the real problem seems to be that you want everything 'visible' in
your IDL file. But why? You should define *your* interfaces in there. If you
want to implement an Excel interface then do it in C++, having #imported the
type library.

Does that help? If not, can you be a bit more precise about what you are
trying to do and what Excel interfaces you are using?

Loz.



Wed, 27 Aug 2003 01:12:48 GMT  
 Passing an Excel COM object to a C++ COM Server
use "importlib" in the idl file instead:

// test68.idl : IDL source for test68.dll
//

// This file will be processed by the MIDL tool to
// produce the type library (test68.tlb) and marshalling code.

import "oaidl.idl";
import "ocidl.idl";

[
 uuid(A723E7C0-14B4-11D5-ACF1-0060B0FCF40A),
 version(1.0),
 helpstring("test68 1.0 Type Library")
]
library TEST68Lib
{
 importlib("stdole32.tlb");
 importlib("stdole2.tlb");
 importlib("G:\\Program Files\\Microsoft Office\\Office\\EXCEL8.OLB");

 [
  object,
  uuid(A723E7CC-14B4-11D5-ACF1-0060B0FCF40A),

  helpstring("IFooBarObj Interface"),
  pointer_default(unique)
 ]
 interface IFooBarObj : IUnknown
 {
  [helpstring("method BarFoo")] HRESULT BarFoo(IRange* pRng);
 };

 [
  uuid(A723E7CD-14B4-11D5-ACF1-0060B0FCF40A),
  helpstring("FooBarObj Class")
 ]
 coclass FooBarObj
 {
  [default] interface IFooBarObj;
 };

Quote:
};

--
Reginald Blue                   | Opinions expressed here do not
Natural Language Understanding  | necessarily represent those of
Unisys Corporation              | my employer.
--------------------------------+-------------------------------

NL technology,speech application| My email address is wrong, you
development training, see:      | need to remove the obvious.
http://www.speechdepot.com/     +-------------------------------


Hi
   I am currently trying to create a COM Server under C++ using ATL. This
COM
server will be accessed by Excel and be given Excel Range Objects. So I need
to
import the Excel type library in my idl file.
   To be able to import the Excel interfaces I used the OLE/COM object
viewer to
open the Excel8.olb file and copied what was displayed in a .idl file. This
worked fine until I tried to build my project : the generated idl file was
filled
with errors.
   Due to the amount of corrections needed, I wondered if there was another
way
to do this.

Thanks.

Laurent



Wed, 27 Aug 2003 02:07:44 GMT  
 Passing an Excel COM object to a C++ COM Server
I want to make a COM Server which will be called by Excel. One of its methods
needs a Range object. For this function to be available to Excel, I have to
declare it in the .idl file, but then the compiler does not recognize the
type 'Range' and states :

error MIDL2025 : syntax error : expecting a type specification near "Range"

I tried adding an importlib in the Library statement, but this does not work.

Here is the source code of the .idl file :

// ExcelServer.idl : IDL source for ExcelServer.dll
//

// This file will be processed by the MIDL tool to
// produce the type library (ExcelServer.tlb) and marshalling code.

import "oaidl.idl";
import "ocidl.idl";

        [
                object,
                uuid(82AAD61D-12D3-11D5-9474-00108302FE54),
                dual,
                helpstring("IExcelObjectServer Interface"),
                pointer_default(unique)
        ]
        interface IExcelObjectServer : IDispatch
        {
                [id(1), helpstring("method CreateObject")] HRESULT CreateObject
(char *Name, VARIANT args, Range ExcelRange);
        };

[
        uuid(82AAD611-12D3-11D5-9474-00108302FE54),
        version(1.0),
        helpstring("ExcelServer 1.0 Type Library")
]
library EXCELSERVERLib
{      
        importlib("stdole32.tlb");
        importlib("stdole2.tlb");

        [
                uuid(82AAD61E-12D3-11D5-9474-00108302FE54),
                helpstring("ExcelObjectServer Class")
        ]
        coclass ExcelObjectServer
        {
                [default] interface IExcelObjectServer;
        };

Quote:
};

Thanks for your help.

Laurent



Fri, 29 Aug 2003 16:35:13 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. passing COM object pointers to another COM object in ATL

2. Passing COM objects as parameters to other COM objects

3. Passing COM objects as parameters to other COM objects

4. passing objects from VB as VARIANT to COM server object failing

5. passing objects from VB as VARIANT to COM server object failing

6. C++ COM-Object with COM-Object as parameter

7. problems passing ADO Recordset from VB-COM client to VC-COM-Server dll

8. Passing a COM object to a non-COM aware class

9. COM/ATL novice:passing object pointers through methods on a COM interface

10. Problems passing objects to in-proc C# COM server from VBS

11. Create instance of an com object inside a the Com server

12. Passing [in,out] VARIANT* to C++/ATL COM server

 

 
Powered by phpBB® Forum Software