Click here to Skip to main content
15,906,766 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: preventative directories Pin
David Crow28-Aug-03 7:12
David Crow28-Aug-03 7:12 
GeneralRe: preventative directories Pin
will138328-Aug-03 7:50
will138328-Aug-03 7:50 
GeneralRe: preventative directories Pin
David Crow28-Aug-03 8:09
David Crow28-Aug-03 8:09 
GeneralPorting VC++ 6.0 -> VC++.net 2003 Help Requested Pin
Larry J. Siddens28-Aug-03 4:27
Larry J. Siddens28-Aug-03 4:27 
GeneralRe: Porting VC++ 6.0 -> VC++.net 2003 Help Requested Pin
valikac28-Aug-03 6:12
valikac28-Aug-03 6:12 
Generalexcel automation Pin
act_x28-Aug-03 4:21
act_x28-Aug-03 4:21 
GeneralRe: excel automation Pin
will138328-Aug-03 4:33
will138328-Aug-03 4:33 
GeneralRe: excel automation Pin
David Crow28-Aug-03 7:19
David Crow28-Aug-03 7:19 
First you'll need to import from Excel's type library. After that, use the classes that are provided. Here a small snippet that gets two values from the user, plugs them into two cells and puts their sum into a third:

_Application    app;
Workbooks       books;
_Workbook       book;
Worksheets      sheets;
_Worksheet      sheet;
Range           range;
COleVariant     vtOptional((long) DISP_E_PARAMNOTFOUND, VT_ERROR),
                vtTrue((short) TRUE),
                vtFalse((short) FALSE);
CString         strText;


if (app.CreateDispatch("Excel.Application") == TRUE)
{
    app.SetVisible(TRUE);

    books = app.GetWorkbooks();

    book = books.Add(vtOptional);

    sheets = book.GetSheets();

    sheet = sheets.GetItem(COleVariant((short) 1));

    range = sheet.GetRange(COleVariant("A1"), COleVariant("A1"));
    m_ebCellA1.GetWindowText(strText);
    range.SetValue(COleVariant(strText));

    range = sheet.GetRange(COleVariant("A2"), COleVariant("A2"));
    m_ebCellA2.GetWindowText(strText);
    range.SetValue(COleVariant(strText));

    range = sheet.GetRange(COleVariant("A4"), COleVariant("A4"));
    range.SetFormula(COleVariant("=A1 + A2"));
}

GeneralRe: excel automation Pin
Malcolm Smart22-Oct-04 11:37
Malcolm Smart22-Oct-04 11:37 
GeneralRe: excel automation Pin
David Crow22-Oct-04 11:42
David Crow22-Oct-04 11:42 
GeneralRe: excel automation Pin
Malcolm Smart28-Oct-04 2:49
Malcolm Smart28-Oct-04 2:49 
GeneralDialog (Modal) based MFC Application, fails to respond properly to 'Minimize-All', 'Restore on click from taskbar-entry', etc Pin
ohadp28-Aug-03 3:34
ohadp28-Aug-03 3:34 
GeneralRe: Dialog (Modal) based MFC Application, fails to respond properly to 'Minimize-All', 'Restore on click from taskbar-entry', etc Pin
David Crow28-Aug-03 3:39
David Crow28-Aug-03 3:39 
GeneralRe: Dialog (Modal) based MFC Application, fails to respond properly to 'Minimize-All', 'Restore on click from taskbar-entry', etc Pin
ohadp28-Aug-03 3:51
ohadp28-Aug-03 3:51 
GeneralCreating and saving to a file Pin
NewHSKid28-Aug-03 2:29
NewHSKid28-Aug-03 2:29 
GeneralRe: Creating and saving to a file Pin
David Crow28-Aug-03 2:40
David Crow28-Aug-03 2:40 
GeneralRe: Creating and saving to a file Pin
NewHSKid28-Aug-03 2:55
NewHSKid28-Aug-03 2:55 
GeneralRe: Creating and saving to a file Pin
Ravi Bhavnani28-Aug-03 3:05
professionalRavi Bhavnani28-Aug-03 3:05 
GeneralRe: Creating and saving to a file Pin
David Crow28-Aug-03 3:06
David Crow28-Aug-03 3:06 
GeneralRe: Creating and saving to a file Pin
NewHSKid28-Aug-03 3:36
NewHSKid28-Aug-03 3:36 
GeneralRe: Creating and saving to a file Pin
David Crow28-Aug-03 3:41
David Crow28-Aug-03 3:41 
Generalchar to WCHAR Pin
arturapps28-Aug-03 2:27
arturapps28-Aug-03 2:27 
GeneralRe: char to WCHAR Pin
David Crow28-Aug-03 2:42
David Crow28-Aug-03 2:42 
Generalrun batch file contents from application...help experts Pin
rohit.dhamija28-Aug-03 2:17
rohit.dhamija28-Aug-03 2:17 
GeneralRe: run batch file contents from application...help experts Pin
David Crow28-Aug-03 2:23
David Crow28-Aug-03 2:23 

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.