Office OCX & Office Component

Office Viewer OCX integrates with  Word Viewer, Excel Viewer and PowerPoint Viewer!

Office Viewer ActiveX Control v3.2

Pick Products>>
EDraw Max

flowchart, organizational chart, network diagram software

Lightweight yet incredibly powerful diagramming tool with rich examples and stencils. Easy to create professional-looking flowcharts, network diagrams, organizational charts and more. Free Download

Documents>>
What's new in the EDraw Office Viewer Component
Solution for the click to activate and user the control
ActiveX Control Digital Signatures / Code Signing
Office Automation Support
Host multiple office viewer component in a form
Upload a file to web server in ASP.NET
How to allow download the unsigned ActiveX control
Relative Resource>>
 

Office Viewer ActiveX Control acts as an ActiveX document container for hosting Word documents in a custom form or Web page. The OCX is lightweight and flexible, and gives developers new possibilities for using Microsoft Office in a custom solution.

Home: http://www.officeocx.com

Online Demo: http://www.officeocx.com/OfficeActiveXOnlineDemo.htm

Support Mail: support@officeocx.com

Sales online: https://www.regnow.com/softsell/nph-softsell.cgi?item=14203-1

Support Office 97, Office 2000, Office XP, or Office 2003 in Windows OS.

 

It can be easily integrated into applications written in languages that support ActiveX control such as Visual C++, Visual Basic, Delphi, C++ Builder and .Net languages. Support Office automating client to custom your application. Include abundant sample codes. You can also get the full c++ source codes.

 

Name: Office Viewer OCX or Office Viewer ActiveX Control

CLSID: 18A295DA-088E-42D1-BE31-5028D7F9B9B5

Version: 3,2,0,5

Release Date: 2007-3-31

OCX Size: 448KB

 

How to add Office ActiveX Control to your Visual Basic 6.0 project 

1.       From the Project Menu select Components…

2.       Select control “Office Viewer ActiveX Control”

3.       Click the OK Button

4.       The control will now appear in your toolbox

5.       Drag and drop the control on your form

There are some methods and properties to operator the office control.

 

Code a solution using the control

The control is very customizable. You can change the color scheme of any of the control elements, as well as determine the border type and a custom caption. These can be set at run time or design time as needed.

1.        Create new documents

Function void CreateNew(BSTR ProgId);

Description: Creates a new document based on the ProgID.

Office Document Type:

Excel Spreadsheet: progID is “Excel.Sheet”;

Excel Chart: ProgID is “Excel.Chart”;

PowerPoint Presentation: ProgID is “PowerPoint.Show”;

Project: ProgID is “MSProject.Project”;

Visio Drawing: ProgID is “Visio.Drawing”;

Word Document: ProgID is “Word.Document”..

The component allows you to create new documents for any ActiveX document type that is registered on the system. A user can use the custom function that you provide to create new documents.

 

2.        Open Local documents

Function: boolean Open(BSTR Path);

Description: Opens a document from a local file.

You can also open and edit Office documents that exist on a local drive. You can call the Open method directly and give the control a specific file to open.

 

3.        Open Web folder

Function: boolean OpenWebFile(BSTR FileUrl);

Description: Opens a document from a web folder.

You can also open and edit Office documents that exist on web folder. Open takes either a qualified file path or a URL to a file on a remote Web server. For example, the following code opens a web file.

OA1. OpenWebFile "http://www.anydraw.com/demo/sample.doc"

 

4.        Show Open File Dialog

Function: boolean OpenLocalDialog ();

Description: Opens a document from a local file with the standard open file dialog.

 

5.        Save Documents

Function: boolean Save(BSTR strPath);

Description: Save the opened file to specify a save location.

 

6.        Show Save File Dialog

Function: void SaveLocalDialog();

Description: Saves a document to a local file with the standard save file dialog.

 

7.        Save Web Folder

Function: void SaveWebFile(BSTR ServerUrl);

Description: Saves a document to a web folder.

Note: In order to save and upload the opened file in the PowerPoint Viewer ActiveX Control, you must write a method in your web server to receive the stream. Please review the full sample codes in the install package

ASP:

private void Save()

{

       Stream stream = Request.InputStream;

       StreamReader sr = new StreamReader(stream);

       string uploadString = sr.ReadToEnd();

       sr.Close();

       stream.Close();

       try

       {

              FileStream fs = new FileStream(@"c:\Test1\test.doc",

FileMode.OpenOrCreate ,FileAccess.Write,FileShare.None);  

              byte[] _fs = Request.ContentEncoding.GetBytes(uploadString);

              fs.Write(_fs,0,_fs.Length);

              fs.Flush();

              fs.Close();

       }

       catch(Exception ex)

       {

              Response.Write(ex.ToString());

       }

}            

 

ASP.NET:  (See  \install path\sample\ASP.NET)

protected void Page_Load(object sender, EventArgs e)

    {

          String Action = Request.QueryString[“Action”]     

        If(Action == “savefile”{ 

string fileName = Request.QueryString["FileName"];

              if (fileName == "") fileName = "temp.ppt";

 

              Stream stream = Request.InputStream;

              byte[] fileByte = new byte[stream.Length];

              stream.Position = 0;

              stream.Read(fileByte, 0, fileByte.Length);

              stream.Close();

              string strTempPath = "c:\\";

       

              string packageFilePath = strTempPath + fileName;

              using (FileStream fileStream = new FileStream(packageFilePath, FileMode.CreateNew))

              {

                 fileStream.Write(fileByte, 0, fileByte.Length);

                 fileStream.Flush();

                 fileStream.Close();

             }

}

    }             

 

PHP:  (See  \install path\sample\SaveFile.php)

<?php

/* PUT data comes in on the stdin stream */

$putdata = fopen("php://input", "r");

 

/* Open a file for writing */

$fp = fopen("test.ppt", "w");

 

/* Read the data 1 KB at a time

   and write to the file */

while ($data = fread($putdata, 1024))

  fwrite($fp, $data);

 

/* Close the streams */

fclose($fp);

fclose($putdata);

?>

 

8.        Close Document

Function: boolean Close();

Description: Closes the currently open document.

 

9.        Print Out

Function: void Print();

Description: Print out the document

 

10.    Get the toolbars’ state

Function: boolean GetToolbarsIsShow ();

Description: Get the toolbars’ state .

 

11.    Show or hide the toolbars

Function: void ShowToolbars(boolean bShow);

Description: Show/Hide whether toolbars should be displayed.

You can open an office document without toolbars as follow:

If OA1.GetToolbarsIsShow = True Then

OA1.ShowToolbars False

Else

OA1.ShowToolbars True

End If

 

12.    Is Modified

Function boo IsDirty();

Description: Returns True/False if file has been altered or needs save.

It returns true when the document has been altered or needs save.

BOOL bDirty = OA1.IsDirty

 

13.    Upload and Download file

Function: 1) boolean HttpUploadFile(BSTR ServerUrl, BSTR LocalFilePath);

2) boolean HttpDownloadFile(BSTR ServerUrl, BSTR LocalFileUrl);

3) boolean FTPUploadFile(BSTR ServerUrl, BSTR LocalFilePath, BSTR UserName, BSTR Password);

4) boolean FTPDownloadFile(BSTR ServerUrl, BSTR LocalFilePath, BSTR UserName, BSTR Password);

Description: Upload and download the file with Http or FTP method.

The ActiveX Control supports upload and download file with HTTP or FTP method. 

Download file with HTTP method: 

OA1.HttpDownloadFile “http://www.anydraw.com/demo/Samples.doc”

Download file with FTP method: 

OA1.FTPDownloadFile “http://www.anydraw.com/demo/Samples.doc, “c:\Samples.doc”, “”, “”

Upload file with HTTP method: 

OA1.HttpUploadFile “http://www.anydraw.com/demo/SaveFile.php”, “c:\Samples.doc”

Download file with HTTP method: 

OA1.HTTPDownloadFile “http://www.anydraw.com/demo/Samples.doc”, “c:\Samples.doc”

 

14.    Automating Office Document

Function: IDispatch* GetIDispatch();

Description: Returns the Automation interface of the document object.

The control also supports a property called GetIDispatch that allows you to obtain a reference to the IDispatch interface of the embedded object. From this interface you can automate the object to perform tasks, edit parts of the document, or gather information about what a user has added or removed. For example, if you have a Word document open, you can use code that resembles the following to add a line of text:

Dim oDoc As Word.Document

Set oDoc = OA1. GetIDispatch

oDoc.Content.Text = "This was added by Automation"

The ability to control the object while the object is embedded is very powerful. 

 

Other Office ActiveX Controls

Word Viewer OCX Word Viewer ActiveX Control acts as an ActiveX document container for hosting Word documents in a custom form or Web page. It solved the requirement to show a word document on a web form and the user can change the document and the changes should be saved to web server. It is po