Solved

Insert OLE Object to CRichEditView.

Posted on 1998-08-25
2
290 Views
Last Modified: 2013-11-19
Hi,
I use CRichEditView class and want to insert a OLE object.
but, AppWizard makes COleInsertDialog. so users are must
select a OLE Object.

I want to make a button which insert a OLE object.

If users push that button, OLE Object(for example Excel) is inserted to CRichEditView automatically.

thank you for reading.
Have a good day!
0
Comment
Question by:chohs
  • 2
2 Comments
 
LVL 2

Accepted Solution

by:
milenvk earned 100 total points
Comment Utility
Here's what you have to do in your CRichEditView derieved class:

// The Excel.Worksheet.8 class ID holder (must have at least VC 5.0 to use it)
struct __declspec(uuid("00020820-0000-0000-C000-000000000046")) ExcelClsidHolder;

// The "Inset Excel Object" command handler
void CTest2View::OnTestInsertItem()
{
  try
  {
    CRichEditCntrItem* pItem = GetDocument()->CreateClientItem (NULL);
    pItem->m_bLock = TRUE;
    pItem->CreateNewItem(__uuidof(ExcelClsidHolder));
    InsertItem(pItem);
    pItem->UpdateItemType();
    pItem->m_bLock = FALSE;
    // Remove the next line if you don't want automatic in-place activation
    pItem->DoVerb(OLEIVERB_SHOW, this);  
  }
  catch(...)
  {
    if (pItem != NULL)
    {
      ASSERT_VALID(pItem);
      pItem->Delete();
    }
    AfxMessageBox("Failed to create Excel 8.0 Worksheet Object");
  }
}

You can replace the class ID of the Excel.Worksheet.8 object above above with the class ID of the object that you like. If you don't want the object to be automatically in-place activated remove the "pItem->DoVerb(OLEIVERB_SHOW, this);" line. Good luck.


0
 
LVL 2

Expert Comment

by:milenvk
Comment Utility
Oh, and if you don't have VC 5.0 you can specify the class Id as follows:

const CLSID clsidXlSheet =
      { 0x00020820, 0x0, 0x0, { 0xC0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x46 } };

or:
CLSID clsidXlSheet;
CLSIDfromString(L"00020820-0000-0000-C000-000000000046", &clsidXlSheet);

In both situations instead of __uuidof(ExcelClsidHolder) in the above example put clsidXlSheet.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now