Solved

Insert OLE Object to CRichEditView.

Posted on 1998-08-25
2
310 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
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()
{
  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
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 } };

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

813 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

10 Experts available now in Live!

Get 1:1 Help Now