none
How to set the page layout in c# program? RRS feed

  • 問題

  • How to set the page layout?
      I would like to know how to set the "size" and "margin".
      Many thanks for your replying.

     

    2007年7月13日 上午 07:10

解答

  • http://msdn2.microsoft.com/de-de/library/microsoft.office.interop.word.pagesetup.pageheight(VS.80).aspx

    設定 page size

     

    Code Snippet

    Microsoft.Office.Interop.Word.Document varDoc = varWord.Documents.Open(ref varFileName, ref varMissing, ref varFalseValue, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing);

    varDoc.PageSetup.PageHeight = 1584;
      varDoc.PageSetup.PageWidth = 333;

     

    http://msdn2.microsoft.com/de-de/library/microsoft.office.interop.word.pagesetup.topmargin(VS.80).aspx

    設定 margin

    Code Snippet

    // Creates a reference to a word document
                    Microsoft.Office.Interop.Word.Document varDoc = varWord.Documents.Open(ref varFileName, ref varMissing, ref varFalseValue, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing, ref varMissing);

    //page margin
      varDoc.PageSetup.TopMargin = 0;
      varDoc.PageSetup.BottomMargin = 0;
      varDoc.PageSetup.LeftMargin = 0;
      varDoc.PageSetup.RightMargin = 0;

     

     

     

    2007年7月13日 上午 08:11