Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. How To Embed Excel and Remove Menu

How To Embed Excel and Remove Menu

Scheduled Pinned Locked Moved ATL / WTL / STL
designtutorialquestiondatabasecom
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mardigin
    wrote on last edited by
    #1

    The following is a snippet is the code that actually embeds excel into my application and then attempts to remove the insert menuitem. I have read through more then one tutorial, but the most important one to note here is the following: http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q180/6/25.asp&NoWebContent=1 If anyone has anyideas of what is wrong with this code please reply. Note: The above tutorial instructs to create a dlg based application, Mine is an MDI application. The above tutorial controls excel, my application embeds and then attempts to control excel. It works fine right up until it calles cbPop.SetVisible(FALSE); Then it falls into the catch: CException e.m_bAutoDelete = 1 CException e.m_bReadyForDelete = 0 The code I have included here shows how I embed excel and display it on the screen. This is all that i do differently from the above tutorial. CBPReportCntrItem *pItem = NULL; CBPReportDoc *pDoc = NULL; CLSID clsid; TRY { //Get the document associated with this view, and be sure it's //valid. pDoc = GetDocument(); ASSERT_VALID(pDoc); //Create a new item associated with this document, and be sure //it's valid. pItem = new CBPReportCntrItem(pDoc); ASSERT_VALID(pItem); // Get Class ID for Excel sheet. // This is used in creation. if(FAILED(::CLSIDFromProgID(L"Excel.sheet",&clsid))) { AfxMessageBox("Failed to create Excel.sheet"); //Any exception will do. We just need to break out of the //TRY statement. AfxThrowMemoryException(); } // Create the Excel embedded item. if(!pItem->CreateNewItem(clsid)) { AfxMessageBox("Failed to create the excel embeded item"); //Any exception will do. We just need to break out of the //TRY statement. AfxThrowMemoryException(); } //Make sure the new CContainerItem is valid. ASSERT_VALID(pItem); // Launch the server to edit the item. pItem->DoVerb(OLEIVERB_SHOW, this); // As an arbitrary user interface design, this sets the // selection to the last item inserted. m_pSelection = pItem; // set selection to last inserted item pDoc->UpdateAllViews(NULL); //Query for the dispatch pointer for the embedded object. In //this case, this is the Excel worksheet. lpDisp = pItem->GetIDispatch(); app.AttachDispatch(lpDisp, TRUE);

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups