Solved

Insert OLE Object to CRichEditView.

Posted on 1998-08-25
2
332 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 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 110
haveThree challenge 22 127
canBalance challenge 34 113
listing all the respondents to a twitter feed - Java 5 49
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Suggested Courses

759 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