Читал статьи на сайте про Office & MFС, но как-то не вышло сделать тоже самое в сабжевой среде.
Выполнял следующие шаги, описанные на http://support.microsoft.com/kb/q178749/
1. Project -> Add Class
2. MFC Class from TypeLib
3. Либо из Registry(Microsoft Excel 11.0 Type Library) либо прямо из файла
4. Добавляю один класс Application (Переименовываю в _Application).
5.
#include"_Application.h"
6. И, не создав ни единого объекта, получаю мнооооого ошибок по генерируемому файлу Debug\excel.tlh:
warning C4278: 'RGB': identifier in type library 'E:\\knell\\dev\\cpp\\AmwayViewer\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
warning C4278: 'RGB': identifier in type library 'E:\\knell\\dev\\cpp\\AmwayViewer\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
warning C4192: automatically excluding 'IFont' while importing type library 'E:\\knell\\dev\\cpp\\AmwayViewer\\EXCEL.EXE'
warning C4192: automatically excluding 'IPicture' while importing type library 'E:\\knell\\dev\\cpp\\AmwayViewer\\EXCEL.EXE'
warning C4278: 'DialogBox': identifier in type library 'E:\\knell\\dev\\cpp\\AmwayViewer\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
warning C4278: 'CopyFile': identifier in type library 'E:\\knell\\dev\\cpp\\AmwayViewer\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
warning C4278: 'ReplaceText': identifier in type library 'E:\\knell\\dev\\cpp\\AmwayViewer\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
warning C4278: 'ReplaceText': identifier in type library 'E:\\knell\\dev\\cpp\\AmwayViewer\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
warning C4278: 'RGB': identifier in type library 'E:\\knell\\dev\\cpp\\AmwayViewer\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
warning C4278: 'RGB': identifier in type library 'E:\\knell\\dev\\cpp\\AmwayViewer\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
warning C4278: 'CopyFile': identifier in type library 'E:\\knell\\dev\\cpp\\AmwayViewer\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
warning C4278: 'DialogBox': identifier in type library 'E:\\knell\\dev\\cpp\\AmwayViewer\\EXCEL.EXE' is already a macro; use the 'rename' qualifier
error C2371: 'FontPtr' : redefinition; different basic types
d:\program files\microsoft visual studio 8\vc\include\comdef.h(312) : see declaration of 'FontPtr'
error C2786: 'BOOL (__stdcall *)(HDC,int,int,int,int)' : invalid operand for __uuidof
error C2923: '_com_IIID' : 'Rectangle' is not a valid template type argument for parameter '_Interface'
d:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(3514) : see declaration of 'Rectangle'
error C3203: '_com_IIID' : unspecialized class template can't be used as a template argument for template parameter '_IIID', expected a real type
error C2786: 'BOOL (__stdcall *)(HDC,int,int,int,int,int,int,int,int)' : invalid operand for __uuidof
error C2923: '_com_IIID' : 'Arc' is not a valid template type argument for parameter '_Interface'
d:\program files\microsoft visual studio 8\vc\platformsdk\include\wingdi.h(2765) : see declaration of 'Arc'
'_com_IIID' : unspecialized class template can't be used as a template argument for template parameter '_IIID', expected a real type
'PicturePtr' : redefinition; different basic types
d:\program files\microsoft visual studio 8\vc\include\comdef.h(326) : see declaration of 'PicturePtr'
error C2504: '_IMsoDispObj' : base class undefined
error C2504: '_IMsoDispObj' : base class undefined
error C2504: '_IMsoDispObj' : base class undefined
error C2146: syntax error : missing ';' before identifier 'GetRGB'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
warning C4183: 'GetRGB': missing return type; assumed to be a member function returning 'int'
error C2061: syntax error : identifier 'MsoRGBType'
error C2061: syntax error : identifier 'MsoRGBType'
error C2061: syntax error : identifier 'MsoRGBType'
error C2504: '_IMsoDispObj' : base class undefined
error C2146: syntax error : missing ';' before identifier 'GetTransparencyColor'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Спасибочки, тогда такой дурацкий вопрос. При таком импорте данное приложение будет работать с любым офисом, то есть все функции Excel статически слинкуются или нет? Или нужно будет таскать еще и DDL ?
Здравствуйте, KneLL, Вы писали: KLL>Спасибочки, тогда такой дурацкий вопрос. При таком импорте данное приложение будет работать с любым офисом, то есть все функции Excel статически слинкуются или нет? Или нужно будет таскать еще и DDL ?
Линкуются динамически через ком. Из этих ДЛЛ берется только информация для компилятора, потом в работе они нужны только для самого офиса.
Скорее всего (99,5%), что будет работать и с последующими версиями офиса, и возможно даже с более ранними. Здесь нужно смотреть и сравнивать интерфейсы офисов.
1>Import MS Excel library...
1>error C2259: 'Excel::Workbooks' : cannot instantiate abstract class
1> due to following members:
1> 'HRESULT IUnknown::QueryInterface(const IID &,void **)' : is abstract
и т.д. все методы класса...
1>>Import MS Excel library...
1>>error C2259: 'Excel::Workbooks' : cannot instantiate abstract class
1>> due to following members:
1>> 'HRESULT IUnknown::QueryInterface(const IID &,void **)' : is abstract
KLL>и т.д. все методы класса...
KLL>
Надо юзать не сами интерфейсы, а смарт-пойнтеры, в данном случае WorkbooksPtr.
вылетает на operator->() для app. Я так понял, что необходимо создать этот самый _Application, но как? new вроде бы не подходит, аналог CreateObject из VB я даже не знаю... Подскажите, плиз...