Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MS Office Type Library Problem

529 views
Skip to first unread message

den...@gmail.com

unread,
May 27, 2007, 6:20:27 AM5/27/07
to
I have a problem importing a Microsoft Office type libraries into my
application. I am using Visual Studio 2005. I tried it with both
#import directive and wizard->AddClass->FromTypeLib. Nothing seems to
work. Lately I found this article: http://support.microsoft.com/kb/307473.
I'm doing exactly as they say, however I'm not able even to compile
the project. Because of a huge amount of errors I receive during
compilation, I think that there some kind of basic problem I can't
find.
Here are some of compilation errors I receive when I try to build
project from http://support.microsoft.com/kb/307473:
--------------------------------------------------------------------------------------------------------------------------
...\debug\excel.tlh(1219) : error C2371: 'FontPtr' : redefinition;
different basic types
c:\program files\microsoft visual studio 8\vc\include\comdef.h(312) :
see declaration of 'FontPtr'
...\debug\excel.tlh(1297) : error C2786: 'BOOL (__stdcall *)
(HDC,int,int,int,int)' : invalid operand for __uuidof
...\debug\excel.tlh(1297) : error C2923: '_com_IIID' : 'Rectangle' is
not a valid template type argument for parameter '_Interface'
c:\program files\microsoft visual studio 8\vc\platformsdk\include
\wingdi.h(3514) : see declaration of 'Rectangle'
...\debug\excel.tlh(1297) : error C3203: '_com_IIID' : unspecialized
class template can't be used as a template argument for template
parameter '_IIID', expected a real type
...\debug\excel.tlh(1301) : error C2786: 'BOOL (__stdcall *)
(HDC,int,int,int,int,int,int,int,int)' : invalid operand for __uuidof
...\debug\excel.tlh(1301) : error C2923: '_com_IIID' : 'Arc' is not a
valid template type argument for parameter '_Interface'
c:\program files\microsoft visual studio 8\vc\platformsdk\include
\wingdi.h(2765) : see declaration of 'Arc'
...\debug\excel.tlh(1301) : error C3203: '_com_IIID' : unspecialized
class template can't be used as a template argument for template
parameter '_IIID', expected a real type
...\debug\excel.tlh(1308) : error C2371: 'PicturePtr' : redefinition;
different basic types
c:\program files\microsoft visual studio 8\vc\include\comdef.h(326) :
see declaration of 'PicturePtr'
...\debug\excel.tlh(1689) : error C2504: '_IMsoDispObj' : base class
undefined
...\debug\excel.tlh(1731) : error C2504: '_IMsoDispObj' : base class
undefined
...\debug\excel.tlh(1852) : error C4430: missing type specifier - int
assumed. Note: C++ does not support default-int
...\debug\excel.tlh(1852) : error C4430: missing type specifier - int
assumed. Note: C++ does not support default-int
--------------------------------------------------------------------------------------------------------------------------
Please advice!
Thanks in advance,
Denis.

SvenC

unread,
May 28, 2007, 2:06:19 PM5/28/07
to
Hi Denis

den...@gmail.com wrote:
> I have a problem importing a Microsoft Office type libraries into my
> application. I am using Visual Studio 2005. I tried it with both
> #import directive and wizard->AddClass->FromTypeLib. Nothing seems to
> work. Lately I found this article:
> http://support.microsoft.com/kb/307473. I'm doing exactly as they
> say, however I'm not able even to compile
> the project. Because of a huge amount of errors I receive during
> compilation, I think that there some kind of basic problem I can't
> find.

I use these #imports without problems in VS2005

// Office
#import "libid:2DF8D04C-5BFA-101B-BDE5-00AA0044DE52" version("2.4")
lcid("0") named_guids raw_dispinterfaces

//Word
#import "libid:00020905-0000-0000-C000-000000000046" version("8.4")
lcid("0") auto_search no_dual_interfaces raw_dispinterfaces
rename("ExitWindows", "wordExitWindows")

// Excel
#import "libid:00020813-0000-0000-C000-000000000046" version("1.6")
lcid("0") auto_search no_dual_interfaces raw_dispinterfaces
rename("DialogBox", "excelDialogBox") rename("RGB", "excelRGB")

// PowerPoint
#import "libid:91493440-5A91-11CF-8700-00AA0060263B" version("2.9")
lcid("0") auto_search no_dual_interfaces raw_dispinterfaces


--
SvenC

den...@gmail.com

unread,
May 29, 2007, 1:01:45 AM5/29/07
to
Hi, SvenC!
Thank you for your answer.
I tried using type libraries in two different ways:

1. I used your #import statement for Excel. When I compiled it, I got
dozens of errors in excel.tlh file.
2. I tried to do import by wizard: Add->Class->MFC type Library-
>Excel. When I do this, wizard creates a wraper slass for each
interface.
As soon as I do #include for an interface class header
(CAplication, for example), compiler finds over two hundred of errors
- all in excel.tlh file.

All this is done in VS2005.

Pleasse advice!

SvenC

unread,
May 29, 2007, 2:14:43 AM5/29/07
to
Hi,

den...@gmail.com wrote:
> Hi, SvenC!
> Thank you for your answer.
> I tried using type libraries in two different ways:
>
> 1. I used your #import statement for Excel. When I compiled it, I got
> dozens of errors in excel.tlh file.

Did you #import the office type lib also?

// Office
#import "libid:2DF8D04C-5BFA-101B-BDE5-00AA0044DE52" version("2.4")
lcid("0") named_guids raw_dispinterfaces

// Excel


#import "libid:00020813-0000-0000-C000-000000000046" version("1.6")
lcid("0") auto_search no_dual_interfaces raw_dispinterfaces
rename("DialogBox", "excelDialogBox") rename("RGB", "excelRGB")

Remember that you must *not* include the tlh file. That is done
automatically.

I never tried the MFC wizard, so I am of no help there.

--
SvenC

akhil...@gmail.com

unread,
Jun 21, 2007, 5:59:50 AM6/21/07
to
On May 29, 11:14 am, "SvenC" <S...@community.nospam> wrote:
> Hi,

hey try this.. worked for me.. maybe works for you as well..
add the foll 2 lines of code(2 #import lines..) at the end of ure
stdafx.h file ..

#import "libid:2DF8D04C-5BFA-101B-BDE5-00AA0044DE52"
version("2.4")lcid("0") named_guids raw_dispinterfaces

#import "libid:00020813-0000-0000-C000-000000000046"
version("1.6")lcid("0") auto_search no_dual_interfaces


raw_dispinterfaces rename("DialogBox", "excelDialogBox") rename("RGB",
"excelRGB")

Do lemme know if that worked. good luck
regards,
Akhil

0 new messages