我还是贴出来吧,供大家讨论,word的
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WinWordControl
{
public class DocumentInstanceException : Exception
{}
public class ValidDocumentException : Exception
{}
public class WordInstanceException : Exception
{}
public class WinWordControl : System.Windows.Forms.UserControl
{ [DllImport("user32.dll")]
public static extern int FindWindow(string strclassName, string strWindowName);
[DllImport("user32.dll")]
static extern int SetParent( int hWndChild, int hWndNewParent);
[DllImport("user32.dll", EntryPoint="SetWindowPos")]
static extern bool SetWindowPos(int hWnd,int hWndInsertAfter,
int X,int Y,int cx,int cy,uint uFlags);
[DllImport("user32.dll", EntryPoint="MoveWindow")]
static extern bool MoveWindow(int hWnd,int X,int Y,int nWidth,int nHeight,bool bRepaint);
const int SWP_DRAWFRAME = 0x20;
const int SWP_NOMOVE = 0x2;
const int SWP_NOSIZE = 0x1;
const int SWP_NOZORDER = 0x4;
private Word.Document document;
private static Word.ApplicationClass wd = null;
public static int wordWnd = 0;
private static string filename = null;
private static bool deactivateevents = false;