//Get the document associated with this view, and be sure it's
//valid.
CEmbed_ExcelDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CEmbed_ExcelCntrItem* pItem = NULL;
pItem = (CEmbed_ExcelCntrItem* )pDoc->GetInPlaceActiveItem(this);
//Make sure the new CContainerItem is valid.
ASSERT_VALID(pItem);
//Query for the dispatch pointer for the embedded object. In
//this case, this is the Excel worksheet.
LPDISPATCH lpDisp;
lpDisp = pItem->GetIDispatch();
//Add text in cell A1 of the embedded Excel sheet
_Workbook wb;
Worksheets wsSet;
_Worksheet ws;
Range range;
_Application app;
//set _Workbook wb to use lpDisp, the IDispatch* of the
//actual workbook.
wb.AttachDispatch(lpDisp);
//Then get the worksheet's application.
app = wb.GetApplication();
range = app.GetActiveCell();
range.SetColumnWidth(COleVariant((long)100));
//Fill A1 with the string "Hello, World!"
range.SetValue(COleVariant("Hello, World!"));