Use C # To insert the header and footer in word,

Source: Internet
Author: User

Use C # To insert the header and footer in word,

// Insert footer

[Csharp]View plaincopyprint?
  1. Public void InsertFooter (string footer)
  2. {
  3. If (ActiveWindow. ActivePane. View. Type = WdViewType. wdNormalView |
  4. ActiveWindow. ActivePane. View. Type = WdViewType. wdOutlineView)
  5. {
  6. ActiveWindow. ActivePane. View. Type = WdViewType. wdPrintView;
  7. }
  8. ActiveWindow. View. SeekView = WdSeekView. wdSeekCurrentPageFooter;
  9. This. Application. Selection. HeaderFooter. LinkToPrevious = false;
  10. This. Application. Selection. HeaderFooter. Range. ParagraphFormat. Alignment = WdParagraphAlignment. wdAlignParagraphCenter;
  11. ActiveWindow. ActivePane. Selection. InsertAfter (footer );
  12. // Jump out of the header and footer settings
  13. ActiveWindow. View. SeekView = WdSeekView. wdSeekMainDocument;
  14. }


 

 

Methods on msdn

[Csharp]View plaincopyprint?
    1. Foreach (Word. Section wordSection in this. Application. ActiveDocument. Sections)
    2. {
    3. Word. Range footerRange = wordSection. Footers [Word. WdHeaderFooterIndex. wdHeaderFooterPrimary]. Range;
    4. FooterRange. Font. ColorIndex = Word. WdColorIndex. wdDarkRed;
    5. FooterRange. Font. Size = 20;
    6. FooterRange. Text = "footer and footer ";
    7. }
    8. Foreach (Word. Section section in this. Application. ActiveDocument. Sections)
    9. {
    10. Word. Range headerRange = section. Headers [Word. WdHeaderFooterIndex. wdHeaderFooterPrimary]. Range;
    11. HeaderRange. Fields. Add (headerRange, Word. WdFieldType. wdFieldPage );
    12. HeaderRange. ParagraphFormat. Alignment = Word. WdParagraphAlignment. wdAlignParagraphRight;
    13. }

C language ^ how to use

A1 = 0x01; // 0000 0001
A2 = 0x00; // 0000 0000
A3 = 0x03; // 0000 0011
A4 = 0x02; // 0000 0010

B1 = a1 ^ a2; // 0000 0001
B2 = a1 ^ a3; // 0000 0010
B3 = a1 ^ a4; // 0000 0011

^ XOR operator. The bitwise value is 0 and the difference is 1. See the example above.

//
Examples of simple and practical problems:
====================================
======= A ======= B =========
There are two circuits on the top. The two switches are a and B respectively. The opening status is \ [1], and the closing status is/[0].
If both circuits are enabled or disabled.
If a turns on [1], B turns off [0], and circuit 1 Powers on
=====================
If a disables [0], B enables [1], and circuit 2 powers on.
====================================
In summary, the circuit fails in the and B states simultaneously [0]. When a and B are different, the power is charged [1].

How to judge prime numbers using C language

A prime number is a number that cannot be divisible by any integer except 1 and itself. For example, 17 is a prime number because it cannot be 2 ~ Any integer in 16. Therefore, to determine whether an integer m is a prime number, you only need to set m to 2 ~ M-1 no integer can be divisible, m is a prime number.
In addition, the judgment method can be simplified. M does not need to be 2 ~ Remove each integer between the numbers expressed as 1 and 2 ~ √ Remove each integer between m. If m cannot be 2 ~ √ Any integer across m, m must be a prime number. For example, to determine whether 17 is a prime number, you only need to enable 17 to be 2 ~ Since each integer between 4 cannot be divisible, 17 is a prime number. (Cause: If m can be 2 ~ If any integer is divisible between expressed on and off, one of the two factors must be less than or equal to √ m, and the other one must be greater than or equal to √ m. For example, 16 can be divided by 2, 4, 8, 16 = 2*8, 2 less than 4, 8 greater than 4, 16 = 4*4, 4 = √ 16, so only 2 ~ There is no factor between 4)
# Include <stdio. h>
# Include <math. h>
Void main ()
{
Int m, I, k;
Printf ("enter an integer :");
Scanf ("% d", & m );
K = (int) sqrt (m );
For (I = 2; I <= k; I ++)
If (m % I = 0)
Break;
If (I> k)
Printf ("% d is a prime number. \ N ", m );
Else
Printf ("% d is not a prime number. \ N ", m );
}

Related Article

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.