怎样用才C#设置纸张大小,页边距,页眉以及段后距的设置,代码要注释。谢谢!!!!

解决方案 »

  1.   

    引用 using Microsoft.Office.Interop.Word;object missing = System.Reflection.Missing.Value;
                object Nothing = System.Reflection.Missing.Value;
                Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
                Microsoft.Office.Interop.Word.Document wordDoc = new Document();
                wordApp.Visible = true;
                wordDoc = wordApp.Documents.Add(ref missing, ref missing, ref missing, ref missing);if (cmbSize.Text == "A5")
                {
                    wordDoc.PageSetup.PaperSize = Microsoft.Office.Interop.Word.WdPaperSize.wdPaperA5;
                    wordDoc.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientLandscape;
                }
                else if (cmbSize.Text == "A4")
                {
                    wordDoc.PageSetup.PaperSize = Microsoft.Office.Interop.Word.WdPaperSize.wdPaperA4;
                    wordDoc.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientPortrait;
                }            //wordApp.Selection.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientLandscape;
                object fileName = @"D:\test\" + DateTime.Now.ToShortDateString() + "\\" + txtTelephone.Text + "   " + DateTime.Now.ToString().Replace(":", ";") + " .doc";
                wordDoc.SaveAs(ref fileName, ref Nothing, ref   Nothing, ref   Nothing, ref   Nothing, ref   Nothing, ref   Nothing, ref   Nothing, ref   Nothing, ref   Nothing, ref   Nothing, ref   Nothing, ref   Nothing, ref   Nothing, ref   Nothing, ref   Nothing);