Edraw Viewer For Word Reference
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
2. Open Local documents
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
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.officeocx.com/demo/sample.doc"
4. Show Open File Dialog
5. Save Documents
6. Save As
If you want to save the opened word document into the html format, you can write codes as follow:
OA1. SaveAs “c:\1.html”, 10
7. Show Save File Dialog
8. Save Web Folder
Note: you must write a Stream receive method in the server. For Example with ASP code: （Please review the full sample codes in the install package）
private void Save()
Stream stream = Request.InputStream;
StreamReader sr = new StreamReader(stream);
string uploadString = sr.ReadToEnd();
FileStream fs = new FileStream(@"c:\Test1\test.doc",
byte _fs = Request.ContentEncoding.GetBytes(uploadString);
You can also write the stream receive method with other language in the server. Review the PHP codes in the follow note.
9. Close Document
It is possible to change the viewer in a way it can only view the word documents.
It is possible to change the viewer in a way it can edit the word documents.
11. Print Out
12. Show or hide the toolbars
You can open an office document without toolbars as follow:
OA1. Open “c:\\sample.xls”
13. Is Modified
It returns true when the document has been altered or needs save.
BOOL bDirty = OA1.IsDirty
14. Upload and Download file
The ActiveX Control supports upload and download file with HTTP or FTP method.
Download file with HTTP method:
Download file with FTP method:
OA1.FTPDownloadFile “http://www.officeocx.com/demo/Samples.doc, “c:\Samples.doc”, “”, “”
Upload file with HTTP method:
OA1.HttpUploadFile “http://www.officeocx.com/demo/SaveFile.php”, “c:\Samples.doc”
Note: you must write a Stream receive method in the server. For Example with PHP code:
/* PUT data comes in on the stdin stream */
$putdata = fopen("php://stdin", "r");
/* Open a file for writing */
$fp = fopen("test.edd", "w");
/* Read the data 1 KB at a time
and write to the file */
while ($data = fread($putdata, 1024))
/* Close the streams */
Download file with HTTP method:
OA1.HTTPDownloadFile “http://www.officeocx.com/demo/Samples.doc”, “c:\Samples.doc”
15. Automating Office Document
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.