disable save, open in the MS Word

We have another issue in which we need your assistant: we need to configure the upper menu bar in MS Word like delete, Save, Open … buttons from this bar (we need to hide such buttons from the end user) and we need to control it from our application.

Also we would like to display print dialog (windows) box when we call Print API, as currently when we call print, it prints immediately without displaying the print window or dialog. 

Your fast response is highly appreciated.

function disableBtn(){

document.OA1.LicenseName = “”;

document.OA1.LicenseKey = “”;

var oDoc = document.OA1.ActiveDocument;

var counter = oDoc.ActiveWindow.Application.CommandBars.Count;

var str = ”;

var subStr = ”;

for(var i = 1; i <= counter;i++){

var name = oDoc.ActiveWindow.Application.CommandBars(i).Name;

var count_control=oDoc.ActiveWindow.Application.CommandBars(i).Controls.Count;

for(var j=1;j<=count_control;j++){

var caption = oDoc.ActiveWindow.Application.CommandBars(i).Controls(j).Caption;

caption = caption.replace(‘&’,”).toLowerCase();

if(caption == ‘save’) {

oDoc.ActiveWindow.Application.CommandBars(i).Controls(j).Enabled=false;

alert(name);

}

}

}

}

Fixed the vulnerable functions of Office Viewer Component

New version has removed the “DeleteLocalFile” method to avoid the attack. Now the component will delete the temporary files when it exits.

We improved the HTTP download file too and provide a securer download method in the version 5.

The follow article is the vulnerable description about the 4.0 version. 

Multiple vulnerabilities have been identified in EDraw Office Viewer Component v4.0, which could be exploited by remote attackers to delete arbitrary files or take complete control of an affected system.

The first issue is caused by a design error in the “DeleteLocalFile()” method within the “edrawofficeviewer.ocx” ActiveX control, which could be exploited by attackers to delete arbitrary files from a vulnerable system by tricking a user into visiting a specially crafted web page.

The second vulnerability is caused by a buffer overflow error in the “edrawofficeviewer.ocx” ActiveX control when processing malformed arguments passed to the “HttpDownloadFile()” method, which could be exploited by remote attackers to execute arbitrary code via a malicious web page.

Handle The Office File Commands

Every time a user selects an item from the File menu or an item on a toolbar that is associated with a file command, the OnFileCommand event is raised. The event allows you to override the default behavior for the control and supply your own custom actions and dialog boxes to do normal file operations.

You can also enable or disable items on the File menu by using the EnableFileCommand property. For example, the following code disables the Open command, and then traps print calls to prevent a user from opening:
Private Sub Form_Load()
OfficeViewer.EnableFileCommand(dsoFileOpen) = False
End Sub
Private Sub Framer1_OnFileCommand(ByVal Item As _
OfficeViewer.FileCommandType, Cancel As Boolean)
If Item = FileOpen Then
MsgBox "You asked to open, but I won't allow it."
Cancel = True
End If
End Sub

How to go to the special item in a Word document via VBA

Q: We have a method “OA1.WordGotoItem wdGoToPage, wdGoToNext”. In a web page this method doesn’t work. Is there any way to use this method in a web page?

A: Referent the follow enums then write the number in the function.

OA1.WordGoToItem 1, 2

Office Automation Interfaces

The EDraw Office Viewer Component provides some simple automation functions. You can call them directly. Or you can get the dispatch interface then do the automation by yourself.

Get Dispatch Interface to support the Office Automation

Function: HRESULT ActiveDocument([out,retval] IDispatch** ppdisp);
Description: Returns the Automation interface of the document object.
  

Function: Application([out,retval] IDispatch** ppdisp);Description: Returns the Automation interface of the application.
  

The control also supports a property called Dispatch 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:

<script language=”vbscript”>
 Sub OfficeAutomationDemo()
 OfficeViewer1.CreateNew “Word.Document”
 Set objWord = OfficeViewer1.ActiveDocument
 objWord.Content.Text = “This was added by Automation”
 End Sub
 </script>
 
 or
 
 <script language=”vbscript”>
 Sub OfficeAutomationDemo()
 OfficeViewer1.CreateNew “Word.Document”
 Set objApp = OfficeViewer1.Application
 objApp.DisplayScrollBars = False
 End Sub
 </script>

Only play a range of slides from within a given

I am use your ActiveX control for a client and am so far very
happy with what I’ve found, with one minor exception. Your control
implements the method

SlideShowOpenAndPlay(Document, bFullScreen, bShowWebToolbar,
bLoopUntilStopped, bShowScrollBar, WebUsername, WebPassword)
and I am wondering if there is a way of specifying a start and end slide
for a show – that is, to only play a range of slides from within a given
presentation? Something like the commandline /R=n-m switch that the
older PowerPoint Viewer application implemented.
Also, how complicated would it be to fire an event when navigating from
the last slide?
Any feedback would be much appreciated.

Open an Excel file and the excel windows seems locked

Hello, I noticed this problem, also in the VB6 sample of the latest version of your OfficeViewer component:

Open an Excel file

Now from my documents (external of the sample program) I try to open another Excel document, with classic double-click; an Excel window show up, but it’s empty and seems “locked” by the OfficeViewer component. I can’t access or close this window until I close the preview.  

There are something that I can do?

Then I tried to open another Excel file externally, from my PC (directly with double click), but attached is the result; the excel windows seems locked, can’t move / close / access.

how do you selectively turn on and off MS Office toolbars and menus

If you would like to be able to turn off and on particular toolbars, follow the codes.

officeviewer1.ActiveDocument.commandbars (“Formatting”).visible = False

Can an ActiveX control be installed in IE without having administrator privileges?

No. Only accounts with the administrative privelege to install OCXs or DLLs can install Active-X controls (by default those accounts are part of the Administrators, Domain Administrators or Power Users groups). But the IE will allow to install the CAB file in the default safe setting.

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();