dot是模板文件,doc才是文档文件。一般word都是先打开normal.dot模板,里面有系统定义的工具栏、格式等,然后打开doc,才是你真正的内容。
你说的利用dot 文件作为打印模板进行打印,应该是先打开一个模版,然后向里面写入东西,在打印吧,跟一般打印也没什么区别,在资源里面搜索"C#打印",应该很快就能找到你要的东西了

解决方案 »

  1.   

    object missing = System.Reflection.Missing.Value;
            if (App == null)
                App = new Word.ApplicationClass();
            App.Visible = true;        object oTemplate = "c:\\mo.dot";
            //试过真接输出到PDF打印机。效率更低
            //App.ActivePrinter = "MS Publisher Color Printer";
            doc = App.Documents.Add(ref oTemplate, ref missing, ref missing, ref missing);
            doc.Activate();
            doc.ActiveWindow.View.ShowFieldCodes = true;
            Word.Books bms = doc.Books;        inputdata(bms,"aaa");
            //foreach (valueinfo  s in clsglo.strarr)
            //{
            //    this.replace(bms,s);
            //}
            oTemplate = Server.MapPath(".") + "\\doc\\2.doc";
            doc.SaveAs(ref oTemplate, ref missing, ref  missing, ref  missing, ref  missing, ref  missing, ref missing, ref missing, ref  missing, ref missing, ref  missing, ref  missing, ref  missing, ref  missing, ref missing, ref  missing);
      

  2.   

    string strfidsql;//得到所有字段
            string strdatasql;//得到数据
            string strbmval;//标签名
            string strtab;//各子表查询Sql
            DataSet  ds = new DataSet();
            DataSet dstab = new DataSet();//用来更新子表        //strfidsql = "SELECT   value as dname,objname as vname  FROM  ::fn_listextendedproperty(NULL,'user','dbo','table','gstab','column',default)";
            //SqlDataAdapter sdafid=new SqlDataAdapter(strfidsql,clsglo.con);
            //sdafid.Fill(ds, "fid");
            strdatasql = "select top 1 * from gstab where gsnum='" + strmd5id + "'";
            SqlDataAdapter sdafid = new SqlDataAdapter(strdatasql, clsglo.con);
            sdafid.Fill(ds, "val");
            //循环所有公司表字段
            object missing = System.Reflection.Missing.Value;        foreach (Word.Book bm in bms)
            {
                if (bm.Name.IndexOf("00") > 0)
                {
                    strbmval = bm.Name.Remove(bm.Name.IndexOf("00"));
                }
                else
                {
                    strbmval = bm.Name;
                }
    }