Click here to Skip to main content
14,743,899 members
Articles » Enterprise Systems » Office Development » General
Posted 2 Nov 2012

Tagged as


18 bookmarked

OLE container surrogate for .NET

Rate me:
Please Sign up or sign in to vote.
4.93/5 (13 votes)
13 Mar 2013CPOL
COM OLE-container analog for .NET


Microsoft Visual Basic versions 6.0 and 5.0 provide an OLE container control for embedding OLE objects directly on forms. The OLE container control provides a means for embedding OLE objects such as Microsoft Excel workbooks, Microsoft PowerPoint presentations, and Microsoft Word documents. But Visual Studio .NET does not provide an OLE container control for Windows Forms: Microsoft recommends achieving a similar functionality by using the Microsoft WebBrowser control to host the document if the document uses ActiveX. Excel, PowerPoint, and Word all support ActiveX. Therefore, documents from those sources may be displayed by using the WebBrowser control.

But the WebBrowser control doesn't embed Office documents because of security problems.

The PreviewContainer control solves this problem.  


  • preview MS Office documents (Excel, Word, PowerPoint and etc) 
  • preview and zooming different image formats like .jpg, .bmp and etc
  • preview and browsing multi-paged .tif files 
  • preview file formats which WebBrowser control support like .htm, .xml, and etc.
  • developers can extend PreviewContainer control for support different file formats 


Excel document preview:

Image 1

Multipages TIFF preview:

Image 2


Solution is based on preview handlers mechanism:

Using the code

Using of this control is very simple: 

  1. Add a reference to PreviewsHandlers.dll
  2. Drop the PreviewContainer on a Windows Form 
  3. Call the CreateLink method of the control with the full file path:
  4. this.previewContainer.CreateLink(@"c:\test.tif");
  5. If you want to browse multi-paged content (like multi-page tif), you can use these methods:
  6. ((IPaginalPreviewHandlerHost)this.previewContainer).PreviousPage();


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Alexei Bouravtsev
Software Developer (Senior) GNIVC
Russian Federation Russian Federation
I'm a Russian (Moscow Aviational Institute 1996-2002) Software Engineer living in Moscow, Russia. I have a long experience in Windows programming and have been developing large GUI, Real Time Enterprise Client/Server C# applications and SQL Server/Oracle databases.

My point of interests is high load enterprise applications.

Comments and Discussions

Questionpossibility of embedding instead of copy local Pin
Eduardo Del Cerro1-Sep-20 0:43
MemberEduardo Del Cerro1-Sep-20 0:43 
QuestionDisable right click menu which are currently displayed on the control Pin
yash150714-Nov-18 0:18
Memberyash150714-Nov-18 0:18 
QuestionOLE container Pin
RufinaTrehub8-Jan-18 8:04
MemberRufinaTrehub8-Jan-18 8:04 
Questionhow do you get hyperlinks work in ppt and docs ? Pin
Member 131136263-Nov-17 21:33
MemberMember 131136263-Nov-17 21:33 
QuestionCan't preview PDF in windows 10 x64 Pin
Belikov Sergey17-Oct-15 7:15
MemberBelikov Sergey17-Oct-15 7:15 
QuestionIs It possible preview by print layout? Pin
Member 448700712-Apr-15 19:56
MemberMember 448700712-Apr-15 19:56 
Questionvisual basic .net Pin
rjmendoza28-Jan-15 15:49
Memberrjmendoza28-Jan-15 15:49 
AnswerRe: visual basic .net Pin
Alexei Bouravtsev3-Feb-15 1:23
MemberAlexei Bouravtsev3-Feb-15 1:23 
Questionedit Pin
Jayson Ragasa22-Nov-14 6:11
MemberJayson Ragasa22-Nov-14 6:11 
AnswerRe: edit Pin
Alexei Bouravtsev3-Feb-15 1:22
MemberAlexei Bouravtsev3-Feb-15 1:22 
QuestionAppears to have issues with more than one Preview Container on a WinForm Pin
gr8yt200028-Jul-14 6:35
Membergr8yt200028-Jul-14 6:35 
QuestionRe: Appears to have issues with more than one Preview Container on a WinForm Pin
TourInfernale26-Feb-15 1:42
MemberTourInfernale26-Feb-15 1:42 
QuestionXLSM? Pin
LunaMirage25-May-14 17:04
MemberLunaMirage25-May-14 17:04 
AnswerRe: XLSM? Pin
Alexei Bouravtsev3-Feb-15 1:25
MemberAlexei Bouravtsev3-Feb-15 1:25 
GeneralRe: XLSM? Pin
Member 819835116-Jul-17 12:06
MemberMember 819835116-Jul-17 12:06 
QuestionGreat Pin
User_Beginner18-Mar-14 9:14
MemberUser_Beginner18-Mar-14 9:14 
QuestionCategory does not exist.? Pin
Member 1018047328-Nov-13 6:14
MemberMember 1018047328-Nov-13 6:14 
AnswerRe: Category does not exist.? Pin
Alexei Bouravtsev25-Mar-14 23:34
MemberAlexei Bouravtsev25-Mar-14 23:34 
QuestionOpen PPT Pin
conqu1212-Sep-13 20:05
Memberconqu1212-Sep-13 20:05 
AnswerRe: Open PPT Pin
Member 1311362612-Oct-17 11:01
MemberMember 1311362612-Oct-17 11:01 
QuestionTry compilation with SharpDevelop 4.3.2 Pin
moebius221-Aug-13 6:55
Membermoebius221-Aug-13 6:55 
AnswerRe: Try compilation with SharpDevelop 4.3.2 Pin
Alexei Bouravtsev25-Mar-14 23:42
MemberAlexei Bouravtsev25-Mar-14 23:42 
QuestionError "Excel has stopped working" Pin
Jason Orphanidis13-Aug-13 1:24
MemberJason Orphanidis13-Aug-13 1:24 
AnswerRe: Error "Excel has stopped working" Pin
Alexei Bouravtsev13-Aug-13 2:50
MemberAlexei Bouravtsev13-Aug-13 2:50 
GeneralMy vote of 5 Pin
Katja240323-Jul-13 23:51
MemberKatja240323-Jul-13 23:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.