Code a solution using the control



EDraw Office Viewer Component V4.1

Overview

EDraw Office Viewer Component contains a standard ActiveX control that acts as an ActiveX document container for hosting Office documents (including Microsoft Word, Microsoft Excel, Microsoft PowerPoint, Microsoft Project, and Microsoft Visio documents) in a custom form or Web page. The control is lightweight and flexible, and gives developers new possibilities for using Office in a custom solution.

The control is designed to handle specific issues that make using ActiveX documents from a non-top-level host window difficult, and serves as a starting place for constructing your own embedded object file viewer or editor as an ActiveX control.

It is a great solution for companies wishing to display read-only Word document data and Excel sheet to their employees while restricting modifications to the underlying data. You can play the PowerPoint file in the same window. You can also display password protected Word documents without supplying passwords to your users - keep your confidential data safe and secure! With the office component it is easy to upload or download file between server and client via HTTP/FTP.

Product Home:

Company Home:

Online Demo:

Support Mail: support@

Sales online:

Requirement

The Server: Windows or Unix Server.

The Client: Office 97, Office 2000, Office XP, Office 2003 or Office 2007

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 in the install directory. You can also get the full c++ source codes.

OCX Information

Name: EDraw Office Viewer Component

File Name: edrawofficeviewer.ocx

CLSID: 053AFEBA-D968-435f-B557-19FF76372B1B

Version: 4,1,5,21

Release Date: 2007-5-20

OCX Size: 916KB

CAB Size: 350KB

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

1. From the Project Menu select Components…

2. Select control “EDraw Office Viewer Component” in the controls table

3. Click the OK Button

4. The control will now appear in your toolbox

5. Drag and drop the control on your form

How to add EDraw Office Viewer Component to your .NET project

1. Open .NET

2. Right-click on the toolbox and select "Choose Items…"

3. Select the COM Components Tab

4. Check EDraw Office Viewer Component and click OK Button

5. The control should appear in the toolbox as "EDraw Office Viewer Component"

6. Double-click on the control to add to your form

7. Resize and move the control on the form as desired

8. Add a button to the form

9. Double-click on the button to access code editor and enter the following code within the Click event:

'Note: Modify code to point to an existing office document file on your web server

EDrawOfficeViewer1.Open ""

10. Change the anchor property of EDrawOfficeViewer1 to Top, Bottom, Left, Right

11. Run the application and click on the button. The Word Document should appear!

How to add EDraw Office Viewer Component to your Access Form

1. Open Access

2. Create a new blank database

3. Create a new form in Design View. You should now be in design mode

4. From the Insert Menu select "ActiveX Control..."

5. Select WordViewer.WordView and click the OK Button

6. The control should appear on the form

7. Resize and move the control on the form as desired

8. Add a button to the form. If the wizard appears cancel it

9. Right-click on the button to invoke the popup menu

10. Select "Build Event..." then select Code Builder and click OK Button

11. You should be inside the Visual Basic Development Environment

12. Within the Command_Click enter the following code:

'Note: Modify code to point to an existing Word Document file on your web server

EDrawOfficeViewer1.Open ""

13. Save your changes and close Visual Basic

14. Save the form and close it

15. Double-click on the form to run it.

16. Click the button. The Word Document should appear!

17. Experiment by changing the file path to a local file such as:

EDrawOfficeViewer1.Open "c:\test.xls"

Visit to view more information.

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.

• Methods

1. Create new documents

Function: boolean CreateNew([in] BSTR ProgIdOrTemplate);

Description: Creates a new document based on the ProgId or Template file provided.

Parameter:

ProgIdOrTemplate: Program Id or Template ID. The following shows the possible values for this parameter.

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”.

Return Value:

Nonzero if successful; otherwise 0.

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.

Create a blank word document:

WebOffice1. CreateNew "Word.Document "

Create a blank excel sheet:

WebOffice1. CreateNew "Excel.Sheet "

2. Open documents

Function: boolean Open([in] VARIANT Document, [in, optional] VARIANT ProgId);

Description: Opens a document from a file, URL.

Parameters:

Document: A full disk path or web url.

ProgId: Described as “CreateNew” function.

Return Value:

Nonzero if successful; otherwise 0.

You can open and edit Office documents that exist on a local drive or a web url. You can call the Open method directly and give the control a specific file to open. If you haven’t specified the ProgId, the component will open the file with the default program. Otherwise it will open the file with the special program.

Some sample codes to demo how to open a file:

VBScript:

Sub OpenDoc()

WebOffice1.Open "c:\testfile.doc"

‘WebOffice1.Open “c:\testfile.rtf”, “Word.Document”

‘WebOffice1.Open “”

‘WebOffice1.Open “”, “Word.Document”

End Sub

JavaScript:

Function OpenDocument()

{

WebOffice1. Open("", “Word.Document”);

//WebOffice1.Open(“c:\testfile.ppt”);

}

Visual C++

BOOL OpenDocument(CString sPath)

{

VARIANT varPath, varOpt;

varPath.vt = VT_BSTR; varPath. boolVal = sPath. AllocSysString();

varOpt.vt = VT_ERROR;

varOpt.scode = DISP_E_PARAMNOTFOUND;

WebOffice1.Open(varpath, varOpt);

}

3. Save Documents

Function: boolean Save([in, optional] VARIANT SaveAsDocument, [in, optional] VARIANT WebUsername, [in, optional] VARIANT WebPassword);

Description: Saves the document to specified location or its original location.

Parameters:

SaveAsDocument: The file save path. If it’s NULL, the opened file will save to its original location.

WebUsername: User name for uploading file to the web server.

WebPassword: User password for uploading file to the web server.

Return Value:

Nonzero if successful; otherwise 0.

You can save the opened file to a local disk file without prompt message with the function. You can also save the opened file to a remote server via HTTP upload.

VBScript:

Sub OpenDoc()

WebOffice1.Save "c:\testfile.doc"

‘WebOffice1.Save “c:\testfile.rtf””

‘WebOffice1.Save “”

‘WebOffice1.Save “”, “UserName”, “Password”

End Sub

JavaScript:

Function OpenDocument()

{

WebOffice1. Save ("", “UserName”, “Password”);

//WebOffice1. Save (“c:\testfile.ppt”);

}

Visual C++

BOOL OpenDocument(CString sPath)

{

VARIANT varPath, varOpt;

varPath.vt = VT_BSTR; varPath. boolVal = sPath. AllocSysString();

varOpt.vt = VT_ERROR;

varOpt.scode = DISP_E_PARAMNOTFOUND;

WebOffice1.Save(varpath, varOpt, varOpt);

}

If you try to save the opened file to remote server with the “Save” method, you need write a receipt page in your web server. Because the component uploads the file by HTTP mode. The follow is some sample code.

:

//Default.aspx

Sub SavetoServer()

OfficeViewer1.Save "”

End Sub

//UploadAction.aspx.cs file

using System;

using System.Collections;

using ponentModel;

using System.Data;

using System.Drawing;

using System.IO;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Xml;

using System.Drawing.Imaging;

using System.Text.RegularExpressions;

public partial class UploadAction : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

if (Request. QueryString["author"] == "name" && Request. QueryString["Data"] == "2")

{

Response.Write("0\n");

Response.Write("We have receipted the right param from Office ActiveX Control.");

}

if (Request.Files.Count == 0)

{

Response.Write("0\n");

Response.Write("There isn't file to upload.");

Response.End();

}

if (Request.Files[0].ContentLength == 0)

{

Response.Write("0\n");

Response.Write("Failed to receipt the data.\n\n");

Response.End();

}

string fullFileName = Server.MapPath(Request.Files[0].FileName);

Request.Files[0].SaveAs(fullFileName);

Response.Write("Upload Successfully.");

Response.End();

}

}

PHP:

ASP:

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download