我想在我的工程中操作Excel ,主要是实现在已有的模板中对某行某列写入值
以下是MSDN中的一个例子:
How to use a type library for Office Automation from Visual C++ .NET
http://support.microsoft.com/kb/307473/EN-US

但是我按照以上的例子操作后编译进错误(主要是重复定义):
c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(1471) : error C2371: 'FontPtr' : redefinition; different basic types
1>        e:\program files\microsoft visual studio 8\vc\include\comdef.h(312) : see declaration of 'FontPtr'
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(1549) : error C2786: 'BOOL (__stdcall *)(HDC,int,int,int,int)' : invalid operand for __uuidof
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(1549) : error C2923: '_com_IIID' : 'Rectangle' is not a valid template type argument for parameter '_Interface'
1>        e:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(3514) : see declaration of 'Rectangle'
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(1549) : error C3203: '_com_IIID' : unspecialized class template can't be used as a template argument for template parameter '_IIID', expected a real type
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(1553) : error C2786: 'BOOL (__stdcall *)(HDC,int,int,int,int,int,int,int,int)' : invalid operand for __uuidof
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(1553) : error C2923: '_com_IIID' : 'Arc' is not a valid template type argument for parameter '_Interface'
1>        e:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(2765) : see declaration of 'Arc'
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(1553) : error C3203: '_com_IIID' : unspecialized class template can't be used as a template argument for template parameter '_IIID', expected a real type
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(1560) : error C2371: 'PicturePtr' : redefinition; different basic types
1>        e:\program files\microsoft visual studio 8\vc\include\comdef.h(326) : see declaration of 'PicturePtr'
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2046) : error C2504: '_IMsoDispObj' : base class undefined
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2088) : error C2504: '_IMsoDispObj' : base class undefined
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2190) : error C2504: '_IMsoDispObj' : base class undefined
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2209) : error C2146: syntax error : missing ';' before identifier 'GetRGB'
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2209) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2209) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2209) : warning C4183: 'GetRGB': missing return type; assumed to be a member function returning 'int'
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2211) : error C2061: syntax error : identifier 'MsoRGBType'
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2230) : error C2061: syntax error : identifier 'MsoRGBType'
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2232) : error C2061: syntax error : identifier 'MsoRGBType'
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2251) : error C2504: '_IMsoDispObj' : base class undefined
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2381) : error C2504: '_IMsoDispObj' : base class undefined
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2420) : error C2504: '_IMsoDispObj' : base class undefined
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2503) : error C2504: '_IMsoDispObj' : base class undefined
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2553) : error C2146: syntax error : missing ';' before identifier 'GetTransparencyColor'
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2553) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2553) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2553) : warning C4183: 'GetTransparencyColor': missing return type; assumed to be a member function returning 'int'
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2555) : error C2061: syntax error : identifier 'MsoRGBType'
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2599) : error C2061: syntax error : identifier 'MsoRGBType'
1>c:\documents and settings\ibahn\my documents\visual studio 2005\projects\testexel\testexel\debug\excel.tlh(2601) : error C2061: syntax error : identifier 'MsoRGBType'
希望各位高手指点!!

解决方案 »

  1.   

    没有啊。
    http://social.msdn.microsoft.com/forums/en-US/vcgeneral/thread/813c66df-95f2-48cf-945b-ba8964255ba3/
    我看到这个说要,重命名才可以。但是我发现:
    C:\Program Files\Common Files\Microsoft Shared\office11\mso.dll没有这个文件 。
      

  2.   

    没有传说中的mso.dll怎么办,是我office安装有问题吗?
      

  3.   

    原来把这句去了就OK了,谢谢您!!!
    #import "C:\\Program Files\\Microsoft Office\\Office12\\EXCEL.EXE" no_namespace