C # Operations Word

Source: Internet
Author: User
Recently because of the project needs, wrote a lot of word2003 programming dongdong. Sometimes encountered problems to check the SDK instructions, it is difficult to find Chinese explanation, for e-wen is not good for me, it is a heavenly book. Presumably many people have regrets.
The following is a list of some commonly used content descriptions that are helpful to everyone.
Let's get started. Note that the following wapp is a Word document engineering variable that I define

Of
Merging cells
Table. Cell (2, 2). Merge (table. Cell (2, 3));

Cell separation
Object rownum = 2;
Object columnnum = 2;
Table. Cell (2, 2). Split (ref rownum, ref columnnum);

Cell alignment
WApp.Selection.Cells.VerticalAlignment = Microsoft.Office.Interop.Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter;

Insert Table row
Table. Rows.Add (ref missing);

Pagination Object IB = Microsoft.Office.Interop.Word.WdBreakType.wdPageBreak;
WApp.Selection.InsertBreak (ref IB);

Line Wrap
WApp.Selection.TypeParagraph ();


Second, Word document settings
WApp.ActiveDocument.PageSetup.LineNumbering.Active = 0; Line number
WApp.ActiveDocument.PageSetup.Orientation = Microsoft.Office.Interop.Word.WdOrientation.wdOrientPortrait; Page orientation
WApp.ActiveDocument.PageSetup.TopMargin = wapp.centimeterstopoints (float. Parse ("2.54")); Top margin
WApp.ActiveDocument.PageSetup.BottomMargin = wapp.centimeterstopoints (float. Parse ("2.54")); Next page margin
WApp.ActiveDocument.PageSetup.LeftMargin = wapp.centimeterstopoints (float. Parse ("3.17")); Left margins
WApp.ActiveDocument.PageSetup.RightMargin = wapp.centimeterstopoints (float. Parse ("3.17")); Right margin
WApp.ActiveDocument.PageSetup.Gutter = wapp.centimeterstopoints (float. Parse ("0")); Gutter position
WApp.ActiveDocument.PageSetup.HeaderDistance = wapp.centimeterstopoints (float. Parse ("1.5")); Header
WApp.ActiveDocument.PageSetup.FooterDistance = wapp.centimeterstopoints (float. Parse ("1.75")); Footer
WApp.ActiveDocument.PageSetup.PageWidth = wapp.centimeterstopoints (float. Parse ("21")); Paper width

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.