EDraw Office Viewer Component for Hosting Office Documents

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 ocx it is easy to upload or download file between server and client via HTTP/FTP.

MORE INFORMATION
This component shows allows developers to embed Office files for in-place editing and viewing. It can be easily integrated into applications written in languages that support ActiveX control such as Visual C++, Microsoft Internet Explorer, Visual Basic, Delphi, C++ Builder and .Net languages to view Office files inside their main solution, and give them programmatic control over the document while it is embedded. 

Solve IE Crash when Onloads Office Document

As you know, if you are using the dsoframer ocx to load a word document, somtime the web page will crash. Aim at the bug, we add an event to solve the issue.

Reasons: When IE parses the pages, it will construct its pages list of Object target automatically. At this same time object will automatically initialize its own. But they are synchronized, non-fixed timing. If IE called ”Open” Interface of the ocx, but the ocx did not prepare its own window, it will lead to the anomaly.

Solution: Independent IE, after the ocx completes the initialization, derived an incident “NotifyCtrlReady”. In “NotifyCtrlReady” incident called Open Interface, can guarantee OCX window well prepared, there will be no anomaly.

Please referent the event interface:

[id(OA_DISPID_NOTIFYCTRLREADY), helpstring("Ready to open document.")]
HRESULT NotifyCtrlReady();

Upload a file to a Web server in ASP.NET

EDraw WebOffice Component provides some methods to upload the file to a web server.

HTTP Post

[id(36), helpstring("Initializes the HTTP connection.")]
   boolean HttpInit();

[id(37), helpstring("Adds the post parameter.")]
   boolean HttpAddpostString([in] BSTR Name, [in] BSTR Value);

[id(38), helpstring("Adds the post file.")]
   boolean HttpAddPostFile([in] BSTR LocalFilePath, [in] BSTR NewFileName);

[id(39), helpstring("Executes the post action.")]
   boolean HttpPost([in] BSTR WebUrl,[in, optional] VARIANT WebUsername, [in, optional] VARIANT WebPassword);

You can use the follow steps to save the opened office document to a web server.

Sub SavetoServer()
    ‘ASP.NET’
    OA1.HttpInit
    OA1.HttpAddpostString “author”, “anyname”
    OA1.HttpAddpostString “Data”, “2007-5-15″
    OA1.HttpAddPostFile “”, “newfilename.doc”
    OA1.HttpPost “http://localhost:1320/Samples/UploadAction.aspx“    
       
    ‘Or you can call the Save method to upload the openned file to the server directly.For examples:
    ‘OA1.Save “http://localhost:1320/Samples/UploadAction.aspx?FileName=newname
End Sub

Note: If the first parameter of “HttpAddPostFile” is blank, the method will upload the opened office file to server.

Then you need to write a ASP.NET Get page to receipt the file.

Review the follow examples:

using System;
using System.Collections;
using System.ComponentModel;
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.Params["author"] == “anyname” && Request.Params["Data"] == “2007-5-15″)
        {
            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();
    }
}

Reference of EDraw Office Viewer Component

EDraw Office Viewer Component V4.0
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: http://www.ocxt.com
Company Home: http://www.edrawsoft.com
Online Demo: http://www.ocxt.com/online-demo/
Support Mail: support@ocxt.com
Sales online: https://www.regnow.com/softsell/nph-softsell.cgi?item=14621-2
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,5,0,20
Release Date: 2007-5-20
OCX Size: 916KB
CAB Size: 350KB

Download the referent at http://www.ocxt.com/download/reference.doc

Avoid the flicker with height=”100%”

If you set the height = “100%” directly for the EDraw Office Viewer Component, then the component starts to flicker like mad.

How to avoid the office component flicker? The follow code is from Yves.

<html>
<head>
<script src=”__embedded_office_functions.js” type=”text/javascript”></script>
<script>
window.onresize = function() {
var con = document.body;
var ele = document.getElementById(’officeApplication’);
ele.style.height = con.offsetHeight;
}
</script>
<script type=”text/javascript” for=”officeApplication” event=NotifyCtrlReady()>
//document.officeApplication.EnableFileCommand(0) = false;
</script>
</head>
<body style=”overflow:hidden;margin:0;padding:0;”>
<object name=”officeApplication” id=”officeApplication” codeBase=”__embedded_office.cab#5,3,406,1″ width=”100%” classid=”clsid:6BA21C22-53A5-463F-BBE8-5CF7FFA0132B” VIEWASTEXT>
<param name=”BorderStyle” value=”0″>
<param name=”Titlebar” value=”0″>
<param name=”Toolbars” value=”1″>
<param name=”LicenseName” value=”tqsoft”>
<param name=”LicenseKey” value=”ED99-5511-123F-AB82″>
<param name=”Menubar” value=”1″>
<param name=”ActivationPolicy” value=”0″>
<param name=”FrameHookPolicy” value=”0″>
<param name=”MenuAccelerators” value=”0″>
</object>
<script language=”JavaScript” type=”text/javascript” src=”NoIEActivate.js”></script>
</body>
</html>

Make embedded Word, Excel document read-only, without using Automation

If you are using EDraw Office Component, you can set the Read-Only property for the opened MS Word and MS Excel.
You needn’t do the office automation by yourself. Only call the “ProtectDocument” method in the component.
[id(55), helpstring("Protects the opened file from modification for Word and Excel. Read Only.")]
boolean ProtectDocument([in, optional] VARIANT Password);
The method will provent anybody to edit the document again. Include to copy or paste the content. It’s very helpful in the online document management system.

How to Save the opened file to server?

Yes, EDraw Web Office Component provides a “save” method to save the opened file to a web server or local hard disk.

[id(27), helpstring("Saves the document to specified location or its original location.")]
boolean Save([in, optional] VARIANT SaveAsDocument, [in, optional] VARIANT WebUsername, [in, optional] VARIANT WebPassword);  

For example:

OA1.Save

OA1.Save “c:\temp.doc”

OA1.Save “http://www.ocxt.com/demo/upload.aspx“, “username”, “password”

 

Upload MS Office File with the VisualSoft FileUpload in the ASP

If you would like to upload the open Microsoft Office file in the asp code, you can use the Visual FileUpload dll by the VisualSoft Technologies Ltd.

Review the following code in the dump.asp page:

 <%@ Language=VBScript %>
 <%
 
 On Error Resume Next
 
 Dim l_oHlp, l_oRequester, l_sPath
 l_sPath = “c:\service\” ‘ you need to modify this
 
 Set l_oRequester = Server.CreateObject(”VisualSoft.FileUpload.1″)
 
 If l_oRequester.GetFileName(”trackdata”) <> “” Then
 l_oRequester.MaxFileSize = l_oRequester.GetFileSize(”trackdata”)
 l_oRequester.GetFileName(”trackdata”)
 l_lUploaderror = CInt(l_oRequester.SaveAnywayAs(”trackdata”, l_sPath & l_oRequester.GetFileName(”trackdata”)))
 If Not l_lUploaderror = 0 Then Response.Write(”upload error:” & l_lUploaderror
 End If
 %>

ActiveX control Definition

An ActiveX control is essentially an OLE or Component Object Model (COM) object. It is a self-registering program or control; that is, it adds registry entries for itself automatically the first time it is run.

An ActiveX control can be as simple as a text box, as complex as an Office Viewer Component, and in some cases as complex as a small application. ActiveX controls are used as controls or dialogs for Internet Web sites, as add-ins to major applications from third-party vendors, and as plug-in utilities. Therefore, ActiveX is synonymous with Java, Netscape plug-ins, and scripting. However, the advantage of ActiveX over these other programming options is that ActiveX controls can also be used in applications written in different programming languages, including all of the Microsoft programming and database languages.

ActiveX controls are not stand-alone solutions. They can only be run from within host applications, such as Internet Explorer, a Microsoft Visual Basic® application, Visual C++® development system, Visual Basic, Delphi, DotNet for Applications, and so on. ActiveX controls facilitate the distribution of specialized controls over networks and the integration of those controls within Web browsers. This includes the ability of the control to identify itself to applications that use ActiveX controls.

ActiveX controls can be scripted from Web pages. This means you can use an ActiveX control to provide a control for a user interface or graphics device interface element. Once created, you can use a scripting language such as Visual Basic Scripting Edition (VBScript) or JavaScript to use the control. Your script instructs the control how to work.

EDraw Office Viewer Component is a standard ActiveX Control. It can be intergrated into the other develop circumstance supports the ActiveX Control.

regsvr32 fails to DllRegisterServer in Vista

Question 

I am using Vista Beta 2 and Web Office Component with Visual Studio 2005.

When attempting to register a COM object (e.g. Active-X component or OCX) with ‘Regsvr32’, i.e.: regsvr32 COM

it fails with a message box displaying:

DllRegisterServer in COM failed.
Return code was: 0×80070005

Where ‘COM’ is the name of the COM object file.

CAUSE

This behavior may occur if you try to register a DLL by using Regsrv32 while you are logged on using an account that does not have administrative credentials, such as an account that is a member of the standard users group. An account that does not have administrative credentials cannot write to the registry or change files in the System32 folder.

The behavior occurs because Windows XP and Windows Server 2003 use a more restrictive security scheme than earlier versions of Windows use. This scheme prevents standard users from registering DLLs.

There are some solutions as follow:

1. Login in as Administrator.

2. Set “Run as Administrator” property of regsvr32.exe  

3. Turned off UAC (User Account Control) in Vista OS.