ILGDRM
asked on
Structured Storage operation for saving Office 2007 Excel documents.
I have VC++ SDI application, which open, modify and save Office 2003 documents uisng OLE. While saving Excel 2003 docs I am able to save this documents properly since Office2003 docs are Structured Storage docs.
I am also able to save Office 2007 Excel (which is not structured storage) with normal data (e.g. Text, Pictures, etc..) docs. But when I am draw Pie-Chart on excel and copy and paste the same pi-chart into same excel doc, Excel documents gets saved but while opening the same document I get "Insufficient Memory to perform Operation." and document gets corrupted.
I need to know how we save such objects (pie-chart) in Office 2007 documents using OLE.
I am also able to save Office 2007 Excel (which is not structured storage) with normal data (e.g. Text, Pictures, etc..) docs. But when I am draw Pie-Chart on excel and copy and paste the same pi-chart into same excel doc, Excel documents gets saved but while opening the same document I get "Insufficient Memory to perform Operation." and document gets corrupted.
I need to know how we save such objects (pie-chart) in Office 2007 documents using OLE.
if (SUCCEEDED(CreateILockBytesOnHGlobal(hMem, FALSE, &pLock)))
{
m_lpRootStg = NULL;
if (SUCCEEDED(StgCreateDocfileOnILockBytes(pLock, STGM_CREATE |
STGM_READWRITE| STGM_SHARE_EXCLUSIVE , 0, &m_lpRootStg)))
{
// Set the class variable
SaveToStorage(NULL);
CommitItems(m_bRemember && !m_bSameAsLoad);
if (m_bRemember)
SetModifiedFlag(FALSE);
// Get a pointer to the memory
if (SUCCEEDED(GetHGlobalFromILockBytes(pLock, &hMem)))
{
PBYTE pByte = (PBYTE) GlobalLock(hMem);
// Get the size
STATSTG StatStg;
if (SUCCEEDED(pLock -> Stat(&StatStg, STATFLAG_DEFAULT)))
{
// Write to our file
CFileException CFE;
CFile outFile;
if (outFile.Open(sName, CFile::modeCreate |
CFile::modeWrite, &CFE))
{
// Write out data
outFile.Write(pByte, StatStg.cbSize.LowPart);
// Cleanup
outFile.Close();
// Show success
bReturn = TRUE;
}
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER