Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Insert OLE Object to CRichEditView.

Posted on 1998-08-25
2
Medium Priority
?
343 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 2

Accepted Solution

by:
milenvk earned 400 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

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

722 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