View RTF formatted string in the office viewer component

Tthis office viewer component could retrieve and save the physical files form the server when we provide the respective file paths.  This component also support to load/save the content of the documents through RTF formatted strings. These strings will be saved and retrieved as it is from the database. The developers can write javascript functions within JSPs to provide access to javascript variables to take these RTF formatted string values.

Firstly, the component can open a rtf file from server with the stream mode.

Referent the following page to write a asp.net page in your server to read file to stream.

http://www.edrawsoft.com/httpopenfilefromstream.php

Then use the following javascript to load the file into component.

<script language=”vbscript”>
Sub DownloadFile()
EDOffice.HttpInit();
EDOffice.HttpAddpostString(“DocumentID”, “name.rtf”);
EDOffice.HttpOpenFileFromStream(“http://localhost:2440/ASPCSharp/UploadAction.aspx”, “Word.Application”);
End Sub
</script>

To save rtf file back to server, you need call the following method.

http://www.edrawsoft.com/httpupload-office-files.php

<script language=”vbscript”>
Sub UploadFile()
EDOffice.HttpInit
EDOffice.HttpAddpostString “author”, “anyname”
EDOffice.HttpAddpostString “Data”, “2010-5-15″
EDOffice.HttpAddPostOpenedFile filename.rtf,  6                 ;wdFormatRTF = 6,
EDOffice.HttpPost “http://localhost:1320/Samples/UploadAction.aspx”
End Sub
< /script>

How do i use InsertBreak and ReplaceText in Office Viewer Component

The ReplaceText method can not do it.

You maybe use the ms word automation to realize it.

The component can get the msword::_Application interface. Then you can do the automation.

For examples in VC:

word::_Application wd;
wd.AttachDispatch(app, FALSE);
if(wd == 0){
wd.DetachDispatch();
return FALSE;
}
BOOL bFindHeader = FALSE;
BOOL bFindBody = FALSE;
BOOL bFindFooter = FALSE;
word::Window win = wd.GetActiveWindow();
word::Pane pane =  win.GetActivePane();
word::View vw = pane.GetView();
{
vw.SetSeekView(9);//wdSeekCurrentPageHeader =9
word::Selection sel = wd.GetSelection();
CHECK_NULL_RETURN(sel, FALSE);
word::Find fd = sel.GetFind();
CHECK_NULL_RETURN(fd, FALSE);
VARIANT vText;
vText.vt = VT_BSTR; vText.bstrVal = strText.AllocSysString();
VARIANT vMatchCase;
vMatchCase.vt = VT_BOOL; vMatchCase.boolVal = MatchCase?VARIANT_TRUE:VARIANT_FALSE;
VARIANT vMatchWholeWord;
vMatchWholeWord.vt = VT_BOOL; vMatchWholeWord.boolVal = MatchWholeWord?VARIANT_TRUE:VARIANT_FALSE;
VARIANT vFalse;
vFalse.vt = VT_BOOL; vFalse.boolVal = VARIANT_FALSE;
VARIANT vTrue;
vTrue.vt = VT_BOOL; vTrue.boolVal = VARIANT_TRUE;
VARIANT vWrap;
vWrap.vt = VT_I4; vWrap.lVal = long(1);
VARIANT vRelpaceAll;
vRelpaceAll.vt = VT_I4; vRelpaceAll.lVal = long(2);
VARIANT vReplaceText;
vReplaceText.vt = VT_BSTR; vReplaceText.bstrVal = strReplaceText.AllocSysString();
bFindHeader = fd.Execute(&vText, &vMatchCase, &vMatchWholeWord, &vFalse, &vFalse, &vFalse, &vTrue,
&vWrap, &vFalse, &vReplaceText, &vRelpaceAll);
fd.ReleaseDispatch();
sel.ReleaseDispatch();

Host multiple Excel and Word components in a form

You can host multiple office component in a form or you can open multiple office instance in your internet explore with Edraw Viewer Component version 7.

The new version 7 has no toolbar-locked issues with multiple instances of Word or excel opened in several tabs or even inside single form.

Note: you need set the Frame hook policy as SetOnFirstOpen and Component activation policy as KeepUIActiveOnAppDeactive in the previous version. But it doesn’t work for the IE7 or IE8.

Frame hook policy
To correctly handle activation when the host gains or loses foreground status, the ActiveX control uses a frame hook. By default, the hook is set when the control is created. In some situations, especially when the control is used from a multi-threaded UI host or when the control is nested in a container control like a Tab page in a .NET WinForm application, the parent of the control at create time may not be the correct window for the control to hook when it is running. In these situations, you can use the FrameHookPolicy property to reset the hook at a more suitable time. For example, if you build a .NET WinForm solution, set the FrameHookPolicy property to SetOnFirstOpen in the Properties window.

Component activation policy
The sample control can support more than one instance of itself in a given host application. However, only one control can be active at a given time. This is a requirement of ActiveX Document hosting. To handle multiple instances in a single host, the control registers itself with a component manager. This lets the component manager keep track of the active control. Use the ActivationPolicy property to control how the embedded object is handled during component changes. The ActivationPolicy property can be set to one or more of the bit flags that are defined by the ActivationPolicy enumeration.

Why do I fail to download the ActiveX control on the client

The failure of loading Office Viewer ActiveX control has the following possible causes:
1. The security settings of IE on the client machine are incorrect.
Please verify the following security settings of IE to “Prompt” or “Enabled”:
a) Download signed ActiveX controls
b) Run ActiveX Controls and plug-ins
c) Script ActiveX controls marked safe for scripting
The dialog box of the security setting can be launched from menu
Tools>Internet Options. Then select the security tab.

Disable Popup Menu in MS Office

You can disable or delete the context menu item in MS Word or Excel by VBA programming.

Word:

OA1.CreateNew “Word.Document”
Set objWord = OA1.ActiveDocument
objWord.Application.CommandBars(“Text”).Controls(“Cu&t”).Enabled = False
objWord.Application.CommandBars(“Text”).Controls(“&Copy”).Enabled = False
objWord.Application.CommandBars(“Text”).Controls(“&Paste”).Enabled = False
‘delete item directly
‘objWord.Application.CommandBars(“Text”).Controls(1).Delete
‘objWord.Application.CommandBars(“Text”).Controls(2).Delete ….

Excel

OA1.Open “c:\text.xls”
Set objExcel = OA1.ActiveDocument
objExcel .Application.CommandBars(“Cell”).Controls(“Cu&t”).Enabled = False
objExcel .Application.CommandBars(“Cell”).Controls(“&Copy”).Enabled = False
objExcel .Application.CommandBars(“Cell”).Controls(“&Paste”).Enabled = False
‘delete item directly
‘objExcel .Application.CommandBars(“Cell”).Controls(1).Delete
‘objExcel .Application.CommandBars(“Cell”).Controls(2).Delete ….

disable some toolbar buttons when a document is opened inside the app

I am using Edraw Word Viewer in my Windows Form application developed using C#.

I need to disable some toolbar buttons when a document is opened inside the app. When user launches MS Word application outside, then the buttons are disabled there too. How can I isolate the toolbar/menubar changes just within the activedocument inside the ActiveX control? I do not want standalone MS Word functions to be affected by the changes within Edraw Word Viewer.

Unable to register the Dll/OCX: Regsvr32 failed with the exit code

Getting this message at a couple of sites:

All have been 64bit Windows 2008 Servers on a Domain but we have also had successful installs on 64bit Windows 2008 Servers on a Domain.

Happens when using the Edraw Install or manually registering with regsvr32.

HttpUpload word document to server

I m facing a problem to used at below code, please help me then i can purchase this component.
http://localhost:1833/test/filename for open to server

http://localhost:1833/test/UploadAction.aspx for save to server
 
then file is not saved and made a tmp file but i want to replace this new doc file
 
i have used this code for save to server
 
function

SavetoServer()
{
if(document.OA1.IsOpened)
{

document.OA1.HttpInit();
var today = new Date();

var myGuid = (today.getMonth()+1).toString();
myGuid += today.getDate().toString();

myGuid += today.getYear().toString();

myGuid += today.getHours().toString();

myGuid += today.getMinutes().toString();

myGuid += today.getSeconds().toString();
var sFileName = myGuid + “.tmp”;
document.OA1.HttpAddPostOpenedFile (sFileName);

document.OA1.HttpPost(

http://localhost:1833/test/UploadAction.aspx“);

if(document.OA1.GetErrorCode() == 0)
{
var sPath = “Save successfully! You can download it http://localhost/” + sFileName;
window.alert(sPath);

}

}
else{
window.alert(

“Please open a document firstly!”);
}

}

Open MS Word or Excel Stream in JSP Program

In order to avoid the temporary file in the server, edraw office  viewer component provided a httpopenfilefromstream method to open the office document from file stream directly. It works in the JSP environment.

For example:

Getfile.jsp example code:

String downloadDirName = request.getSession().getServletContext().getRealPath(DOWNLOAD_RELATIVE_PATH);
 String downloadFileName = downloadDirName + “/” + fileMap.get(PARAM_DOCUMENT_ID).getString();
 File downloadFile = new File(downloadFileName);
 if (downloadFile.exists()) {
  byte[] buffer = new byte[4096];
  BufferedOutputStream output = null;
  BufferedInputStream input = null;
  try {
   output = new BufferedOutputStream(response.getOutputStream());
   input = new BufferedInputStream(new FileInputStream(downloadFileName));
   output.write(“EDA_STREAMBOUNDARY”.getBytes());
   int n = -1;
   while ((n = input.read(buffer, 0, buffer.length)) > -1) {
    output.write(buffer, 0, n);
   }
   output.write(“EDA_STREAMBOUNDARY”.getBytes());
   output.flush();
  } catch(Exception e) {
   e.printStackTrace();
  } finally {
   if (output != null) output.close();
   if (input != null) input.close();
  }
 }
 else {
  System.out.println(“[OfficeViewer Error] 404 File not found!”);
  System.out.println(fileItemList.toString());
 }

Open example code:

$(“OA1″).HttpInit();
$(“OA1″).HttpAddpostString(“DocumentID”, “sample.doc”);
$(“OA1″).HttpOpenFileFromStream(“http://192.168.1.1:8020/path/getfile.jsp“);

broken macros in the documents

we have big problems with the alert when there are broken macros in the documents.

The alert window opens in the background and the user can’t see it.

Could you try to give the alert box the focus and bring it to front?