C # Some Basic Methods for operating word (printing word, inserting a file, inserting an image, locating the header and footer, and removing the horizontal line)

Source: Internet
Author: User

1. Microsoft. Office. Interop. Word. Application wordApp = new ApplicationClass ()

Word object

2. Microsoft. Office. Interop. Word. Document wordDoc = wordApp. Documents. Add (ref Nothing, ref Nothing) Document Object

3. A common parameter of Object Nothing = System. Reflection. Missing. Value

4. wordApp. ActiveWindow. ActivePane. View. SeekView = WdSeekView.

WdSeekCurrentPageHeader: locate the header

5. wordApp. Selection. ParagraphFormat. Borders [WdBorderType. wdBorderBottom]

. LineStyle = WdLineStyle. wdLineStyleNone remove the header line

6. wordApp. ActiveWindow. View. SeekView = WdSeekView. wdSeekMainDocument jumps out of the header.

7. wordApp. Selection. ParagraphFormat. Alignment = WdParagraphAlignment.

WdAlignParagraphCenter aligment (center)

8. Microsoft. Office. Interop. Word. Table policyTab = wordDoc. Tables. Add

(WordApp. Selection. Range, number of rows, column, ref Nothing, ref Nothing); Create a table

9. wordApp. Selection. GoTo (ref oGoToItem, ref oGoToLast, ref Nothing, ref Nothing); locate the page (this is to move the cursor to the end of the content)

10. wordApp. Selection. InsertBreak (ref Nothing); insert a subscriber

11. wordApp. Selection. InsertFile (nofile, ref Nothing, ref contenFalse); insert a file

12. wordApp. Selection. InlineShapes. AddPicture (picName, ref LinkToFile, ref SaveWithDocument, ref Nothing); insert an image

13. wordApp. ActiveWindow. ActivePane. View. SeekView = WdSeekView.

WdSeekCurrentPageFooter; locate the footer

14. wordApp. Selection. TypeText ("write the text to be output at the specified position here"); text input

15. wordDoc. ComputeStatistics (WdStatistic. wdStatisticPages, ref Nothing); get the page number

16. wordDoc. PrintOut (ref Nothing,

Ref Nothing,

Ref Nothing,

Ref Nothing,

Ref Nothing, ref Nothing, ref Nothing );

Call the printer to print (the default printer is called)

17. wordDoc. Close (ref saveChanges, ref Nothing, ref Nothing); document exit

18. wordApp. Quit (ref Nothing, ref Nothing, ref Nothing); exit the word Program

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.