Click here to Skip to main content
15,892,161 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Help with Mouse Button and counter Pin
Iain Clarke, Warrior Programmer31-Mar-09 1:46
Iain Clarke, Warrior Programmer31-Mar-09 1:46 
GeneralRe: Help with Mouse Button and counter Pin
Member 2362621-Apr-09 3:06
Member 2362621-Apr-09 3:06 
Questionfatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h></windows.h> Pin
Le@rner30-Mar-09 23:41
Le@rner30-Mar-09 23:41 
AnswerRe: fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include Pin
Stuart Dootson31-Mar-09 0:07
professionalStuart Dootson31-Mar-09 0:07 
GeneralRe: fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include Pin
Le@rner31-Mar-09 0:51
Le@rner31-Mar-09 0:51 
GeneralRe: fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include Pin
Stuart Dootson31-Mar-09 0:57
professionalStuart Dootson31-Mar-09 0:57 
GeneralRe: fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include Pin
Le@rner31-Mar-09 0:59
Le@rner31-Mar-09 0:59 
GeneralRe: fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include Pin
Stuart Dootson31-Mar-09 1:06
professionalStuart Dootson31-Mar-09 1:06 
As I said, the Excel reading code is independent of WTL or MFC. The important line is this one:

#import ".\EXCEL.EXE" \
	rename( "DialogBox", "ExcelDialogBox" ) \
	rename( "RGB", "ExcelRGB" ) \
	rename( "CopyFile", "ExcelCopyFile" ) \
	rename( "ReplaceText", "ExcelReplaceText" )


That imports the Excel type library into your C++ program, using smart pointers and managed variants and BSTRs.

Look for the string Excel:: in MainDlg.cpp from that article - that shows you the bits of code that are interfacing with Excel.

For example:


  1. Start Excel


    Excel::_ApplicationPtr pApplication;
    
    if ( FAILED( pApplication.CreateInstance( _T("Excel.Application") ) ) )
    {
        Errorf( _T("Failed to initialize Excel::_Application!") );
        return;
    }
    


  2. Load an Excel workbook


    _variant_t  varOption( (long) DISP_E_PARAMNOTFOUND, VT_ERROR );
    
    Excel::_WorkbookPtr pBook = pApplication->Workbooks->Open( dlgFile.m_szFileName, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption );
    


  3. Get the first worksheet


    Excel::_WorksheetPtr pSheet = pBook->Sheets->Item[ 1 ];



Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

GeneralRe: fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include Pin
Rajesh R Subramanian31-Mar-09 2:34
professionalRajesh R Subramanian31-Mar-09 2:34 
QuestionHow to create a listbox in win32 with checkbox style Pin
nbugalia30-Mar-09 22:52
nbugalia30-Mar-09 22:52 
AnswerRe: How to create a listbox in win32 with checkbox style Pin
Iain Clarke, Warrior Programmer30-Mar-09 23:14
Iain Clarke, Warrior Programmer30-Mar-09 23:14 
GeneralRe: How to create a listbox in win32 with checkbox style Pin
nbugalia30-Mar-09 23:40
nbugalia30-Mar-09 23:40 
GeneralRe: How to create a listbox in win32 with checkbox style Pin
Stephen Hewitt30-Mar-09 23:50
Stephen Hewitt30-Mar-09 23:50 
QuestionRe: How to create a listbox in win32 with checkbox style Pin
David Crow31-Mar-09 3:33
David Crow31-Mar-09 3:33 
Questionreading html file in c++/vc++ Pin
siddunelogi30-Mar-09 22:41
siddunelogi30-Mar-09 22:41 
AnswerRe: reading html file in c++/vc++ Pin
Rajesh R Subramanian30-Mar-09 22:48
professionalRajesh R Subramanian30-Mar-09 22:48 
AnswerRe: reading html file in c++/vc++ Pin
Iain Clarke, Warrior Programmer30-Mar-09 23:19
Iain Clarke, Warrior Programmer30-Mar-09 23:19 
QuestionRetrive data from SQL database & store it in Excel file Pin
diptipanchal30-Mar-09 22:31
diptipanchal30-Mar-09 22:31 
AnswerRe: Retrive data from SQL database & store it in Excel file Pin
Purish Dwivedi30-Mar-09 23:12
Purish Dwivedi30-Mar-09 23:12 
GeneralRe: Retrive data from SQL database & store it in Excel file Pin
diptipanchal31-Mar-09 0:10
diptipanchal31-Mar-09 0:10 
QuestionRe: Retrive data from SQL database & store it in Excel file Pin
David Crow31-Mar-09 3:44
David Crow31-Mar-09 3:44 
AnswerRe: Retrive data from SQL database & store it in Excel file Pin
diptipanchal31-Mar-09 18:16
diptipanchal31-Mar-09 18:16 
GeneralRe: Retrive data from SQL database & store it in Excel file Pin
David Crow1-Apr-09 2:49
David Crow1-Apr-09 2:49 
QuestionCreating a language pack............ Pin
Purish Dwivedi30-Mar-09 22:22
Purish Dwivedi30-Mar-09 22:22 
AnswerRe: Creating a language pack............ Pin
Iain Clarke, Warrior Programmer30-Mar-09 23:39
Iain Clarke, Warrior Programmer30-Mar-09 23:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.