Recently have been trying to use vc#2005 to do an embedded Word/office WinForm program, the main solution is as follows:
1, directly through the API to put Word/office window handle to WinForm (feeling more complex);
2, through the web BROWSER;
3, the use of Dsoframer.
I have tested a bit, feel dsoframer more in line with their desire, so decided to use Dsoframer to achieve.
Operation Steps:
WinForm
1, download Dsoframer_kb311765_x86.exe from Microsoft website, untie will get dsoframer.ocx;
2, the Dsoframer.ocx copy to the system directory, and register, I wrote a reg.bat to achieve: Copy dsoframer.ocx C:\windows\system32\dsoframer.ocx regsvr32.exe c : \windows\system32\dsoframer.ocx
3, start VS2005, create a new WinForm C # program;
4, in the Design toolbar, the new add options, in the pop-up page Select the "tab" page, and then browse, select C:\windows\system32\dsoframer.ocx to add, the Design toolbar will see this tool, the name "DSO framer CONTROL OBJECT ";
5. Drag the tool into a design form window, where the following lines are added in the code file: private Axdsoframer.axframercontrol axFramerControl1;
6, open the file, This.axFramerControl1.Open (_filepath);//Note: _filepath is a. doc or. xls suffix file;
7, at this time can be directly on the open Word/excel edit save and so on. Note: In the course of operation, found to press the Print Preview button to close, will cause word/excel error, looked for a long time, and then directly installed OFFICE2003 SP3, haha, fix the bug, will not error.
This article from http://www.cnblogs.com/tianfu/archive/2009/05/07/1452047.html
Web
1. Copy the Dsoframer.ocx to the c:\windows\system32\
2. Double-click the run Regocx.bat file to use the Dsoframer control in VS2010:
1. In the Toolbox, add the item, and in the COM tab, select the Registered Dsoframer control.
2. Drag the DSO Framer control from the common control onto the form.
3. Open Office File Code in DSO: This.axFramerControl1.Open ("C:\\test.xls");
4. Save the Office file code:
private void Button1_Click (object sender, EventArgs e)
{ This.axFramerControl1.Open ("C:\\Documents and settings\\administrator\\ desktop \ \ Copy new Microsoft Word document. doc"); }
private void button2_click (object sender, EventArgs e)
{this.axFramerControl1.Save ("c:\\ Documents and settings\\administrator\\ Desktop \\111111111 documentation. Doc ", True," myname "," Mypass "); }