troubleshooting Question

Structured Storage operation for saving Office 2007 Excel documents.

Avatar of ILGDRM
ILGDRM asked on
System ProgrammingMicrosoft Development
2 Comments1 Solution707 ViewsLast Modified:
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.
if (SUCCEEDED(CreateILockBytesOnHGlobal(hMem, FALSE, &pLock)))
   m_lpRootStg = NULL;
   if (SUCCEEDED(StgCreateDocfileOnILockBytes(pLock, STGM_CREATE | 
    // Set the class variable
   CommitItems(m_bRemember && !m_bSameAsLoad);
   if (m_bRemember)
     // 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
                                // Show success
                                bReturn = TRUE;
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros