-
September 10th, 2009, 02:27 PM
#1
Excel applications in MFC
Hello all,
I am developing a project and want to use excel in it. I have followed all the steps which Microsoft has provided http://support.microsoft.com/kb/307473/EN-US/ and still I have few problems
In step 6 when I add #include "CApplication.h" to "AutoProject.cpp", I am getting a lot of errors.
Code:
1>------ Build started: Project: AtPr, Configuration: Debug Win32 ------
1>Compiling...
1>AtPr.cpp
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(982) : error C2371: 'FontPtr' : redefinition; different basic types
1> c:\program files\microsoft visual studio 9.0\vc\include\comdef.h(327) : see declaration of 'FontPtr'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1060) : error C2786: 'BOOL (__stdcall *)(HDC,int,int,int,int)' : invalid operand for __uuidof
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1060) : error C2923: '_com_IIID' : 'Rectangle' is not a valid template type argument for parameter '_Interface'
1> c:\program files\microsoft sdks\windows\v6.0a\include\wingdi.h(3667) : see declaration of 'Rectangle'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1060) : 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:\projects\tt\atpr\atpr\debug\excel9.tlh(1060) : error C2955: '_com_IIID' : use of class template requires template argument list
1> c:\program files\microsoft visual studio 9.0\vc\include\comip.h(40) : see declaration of '_com_IIID'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1064) : error C2786: 'BOOL (__stdcall *)(HDC,int,int,int,int,int,int,int,int)' : invalid operand for __uuidof
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1064) : error C2923: '_com_IIID' : 'Arc' is not a valid template type argument for parameter '_Interface'
1> c:\program files\microsoft sdks\windows\v6.0a\include\wingdi.h(2914) : see declaration of 'Arc'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1064) : 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:\projects\tt\atpr\atpr\debug\excel9.tlh(1064) : error C2955: '_com_IIID' : use of class template requires template argument list
1> c:\program files\microsoft visual studio 9.0\vc\include\comip.h(40) : see declaration of '_com_IIID'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1071) : error C2371: 'PicturePtr' : redefinition; different basic types
1> c:\program files\microsoft visual studio 9.0\vc\include\comdef.h(341) : see declaration of 'PicturePtr'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1358) : error C2504: '_IMsoDispObj' : base class undefined
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1400) : error C2504: '_IMsoDispObj' : base class undefined
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1502) : error C2504: '_IMsoDispObj' : base class undefined
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1519) : error C2146: syntax error : missing ';' before identifier 'GetRGB'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1519) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1519) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1519) : warning C4183: 'GetRGB': missing return type; assumed to be a member function returning 'int'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1521) : error C2061: syntax error : identifier 'MsoRGBType'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1534) : error C2061: syntax error : identifier 'MsoRGBType'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1536) : error C2061: syntax error : identifier 'MsoRGBType'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1547) : error C2504: '_IMsoDispObj' : base class undefined
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1849) : error C2146: syntax error : missing ';' before identifier 'GetTransparencyColor'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1849) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1849) : warning C4183: 'GetTransparencyColor': missing return type; assumed to be a member function returning 'int'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1851) : error C2061: syntax error : identifier 'MsoRGBType'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(1906) : error C2504: '_IMsoDispObj' : base class undefined
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(4556) : error C2011: 'Font' : 'struct' type redefinition
1> c:\program files\microsoft visual studio 9.0\vc\include\comdef.h(325) : see declaration of 'Font'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(6741) : warning C4003: not enough actual parameters for macro 'DialogBoxW'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(6741) : error C2059: syntax error : ','
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(15800) : error C2011: 'Picture' : 'struct' type redefinition
1> c:\program files\microsoft visual studio 9.0\vc\include\comdef.h(339) : see declaration of 'Picture'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(16759) : error C2146: syntax error : missing ';' before identifier 'Scripts'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(16759) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62282) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62282) : error C2497: 'MsoRGBType' : 'implementation_key' can only be applied to function declarations
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62282) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62283) : error C2146: syntax error : missing ')' before identifier 'RGB'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62283) : error C2182: 'PutRGB' : illegal use of type 'void'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62283) : error C2497: 'ColorFormat::PutRGB' : 'implementation_key' can only be applied to function declarations
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62283) : error C2350: 'ColorFormat::PutRGB' is not a static member
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62346) : error C2497: 'MsoRGBType' : 'implementation_key' can only be applied to function declarations
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62346) : error C2086: 'int MsoRGBType' : redefinition
1> c:\projects\tt\atpr\atpr\debug\excel9.tlh(62282) : see declaration of 'MsoRGBType'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62346) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62347) : error C2146: syntax error : missing ')' before identifier 'TransparencyColor'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62347) : error C2182: 'PutTransparencyColor' : illegal use of type 'void'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62347) : error C2497: 'PictureFormat::PutTransparencyColor' : 'implementation_key' can only be applied to function declarations
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62347) : error C2350: 'PictureFormat::PutTransparencyColor' is not a static member
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62347) : error C2440: 'initializing' : cannot convert from 'int' to 'void (void)'
1> There are no conversions to function types, although there are conversions to references or pointers to functions
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62347) : error C2059: syntax error : ')'
1> c:\program files\microsoft visual studio 9.0\vc\include\comdef.h(325) : see declaration of 'Font'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62468) : error C2027: use of undefined type 'Font'
1> c:\program files\microsoft visual studio 9.0\vc\include\comdef.h(325) : see declaration of 'Font'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62469) : error C2027: use of undefined type 'Font'
1> c:\program files\microsoft visual studio 9.0\vc\include\comdef.h(325) : see declaration of 'Font'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62470) : error C2027: use of undefined type 'Font'
1> c:\program files\microsoft visual studio 9.0\vc\include\comdef.h(325) : see declaration of 'Font'
1>c:\projects\tt\atpr\atpr\debug\excel9.tlh(62470) : fatal error C1003: error count exceeds 100; stopping compilation
1>Build log was saved at "file://c:\Projects\TT\AtPr\AtPr\Debug\BuildLog.htm"
1>AtPr - 187 error(s), 25 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Can someone please tell me how can I solve this problem and is there any other good tutorial to lear how to automate Excel using MFC.
Thanks in Advance
-
October 21st, 2011, 01:48 AM
#2
Re: Excel applications in MFC
I too have received this error when I added a new dialog to my application. I had mistakenly derived it from CDialogEx instead of CDialog. This added a #include <afxtoolbars.h> or some such header file line to my stdafx.h file. (I removed this line before replying to this post, so I don't remember exactly)
This caused a conflict with the definitions for excel automation header.
Removing the include file line in stdafx.h, and deriving from CDialog instead of CDialogEx solved this problem for me...
Hope this helps some poor hapless soul solve his problem... As a general hint, if such problems seem to be occurring after some recent code change to existing code, compare the two versions of code to zero in on such issues....
Cheers,
Zorro
-
April 1st, 2014, 06:29 AM
#3
Re: Excel applications in MFC
Hahaha, would you believe it? I got this problem again, and searched for a solution. Ended up finding my own post! Now that's what I call contributing! ![Smilie](images/smilies/smile.gif)
BTW, the header file name is <afxcontrolbars.h> ... What do you know, I just improved my own answer after 3 years or so!
-
April 6th, 2014, 02:42 AM
#4
Re: Excel applications in MFC
Hi,
I did this once and I was helped by people on this forum. Plz check the following link.
http://forums.codeguru.com/showthrea...ighlight=Excel
But i used VC6.0.
Zulfi.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|