Address: http://blog.joycode.com/kaneboy/archive/2004/11/03/37889.aspx
Word is opened in IE at the link of idea document. Many people may be interested in this question. Therefore, write a blog to give a rough description of the method.
After Office2003 is installed, an ActiveX control is installed in the system, which is located in "Program Files \ Microsoft Office \ OFFICE11 \ owssupp. dll ". Through this control, JavaScript on the client page can activate the local Office software to open and edit Office documents. (In addition, Office XP should already contain this ActiveX Control .)
First, use a Script to create a local object:
OpenDocObj = new ActiveXObject ("SharePoint. OpenDocuments.2"); // to be compatible with Office XP, you can create "SharePoint. OpenDocuments.1"
Then, call the corresponding method of openDocObj. For example, open an Office document on the server:
OpenDocObj. ViewDocument ("http://www.abc.com/documents/sample.doc ");
The opendocobjobject uses different officedocument (.doc).xls0000.ppt) to open different programs (Word, Excel, and PowerPoint ). The ViewDocument () method also has an overload signature, which allows us to manually specify which program to activate to open the document:
OpenDocObj. ViewDocument ("http://www.abc.com/documents/sample.doc", ProgID of the program to be activated );
How do I open the Office program and edit files online?
OpenDocObj. EditDocument ("http://www.abc.com/documents/sample.doc ");
You can directly activate Word, edit the document in Word, and then click Save in Word to save the file to the server. Note: In order for Word to directly Save the edited document to the server, the Windows Identity in the current context of the Web site must be in the corresponding directory of the server (that is, the physical path on the server corresponding to the virtual directory "http://www.abc.com/documents.pdf) you have the write permission. Otherwise, the SAVE action fails. After editing, EditDocument () returns a bool value to indicate whether the editing operation is successful.
We can also open a document template on the server to create a new document:
OpenDocObj. CreateNewDocument ("http://www.abc.com/documents/sampleTemplate.dot", "http://www.abc.com/documents ");
You can use /". The program used to create a new document depends on the template file type (for example, the. dot template corresponds to the Word ). You also need to pay attention to permissions when saving new documents. The CreateNewDocument () method returns a bool value to indicate whether the operation is successful.
The first parameter of the CreateNewDocument () method, in addition to using a template address, can also be directly specified as the ProgID of the client program to create a new document.
Note:
In Windows 2003, the WebDAV protocol is disabled by default, which limits the storage of Office documents.
The WebDAV open method is as follows:
1. Enable IIS6
2. Enable Web Service Extension
3. Right-click WebDAV and choose Allowed.