Insert OLE Object to CRichEditView.

Posted on 1998-08-25
Last Modified: 2013-11-19
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!
Question by:chohs
  • 2

Accepted Solution

milenvk earned 100 total points
ID: 1321284
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()
    CRichEditCntrItem* pItem = GetDocument()->CreateClientItem (NULL);
    pItem->m_bLock = TRUE;
    pItem->m_bLock = FALSE;
    // Remove the next line if you don't want automatic in-place activation
    pItem->DoVerb(OLEIVERB_SHOW, this);  
    if (pItem != NULL)
    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.


Expert Comment

ID: 1321285
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 } };

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

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
not able to insert into temp table 68 173
Looking for a specific application/software 2 119
EvenOdd challenge 10 142
c++  placing data into a form and an editbox 5 21
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
In an interesting question ( here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

679 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