none
C#NET2008 Microsoft WORD 2003 Document Footer Setup RRS feed

  • Question

  • Hullo Friends,

    Please help me. I need your help.

    I am encountering another problem when using C#NET2008 and Microsoft WORD 2003 document Page Number at the Footer. Currently the Heigth of the Footer is 0.5"

    I am having problem try to create C#NET coding to setup the WORD Document Footer.  I am trying to setup the layout at  FOOTER to 0.1"

    Appreciate your help. Thank you.


    Thank you very Much, Have a Good Day. Cheers, Lennie
    Tuesday, January 4, 2011 5:57 AM

Answers

  • Hi Lennie

    wdDoc.PageSetup.FooterDistance = wdApp.InchesToPoints(0.1);


    Cindy Meister, VSTO/Word MVP
    Tuesday, January 4, 2011 9:01 AM
    Moderator
  • To make a value specifically of type float in C#, simply add the character f after the number: (0.1f)
    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Tee Leong Tuesday, January 4, 2011 11:22 PM
    Tuesday, January 4, 2011 4:32 PM
    Moderator

All replies

  • Hi Lennie

    wdDoc.PageSetup.FooterDistance = wdApp.InchesToPoints(0.1);


    Cindy Meister, VSTO/Word MVP
    Tuesday, January 4, 2011 9:01 AM
    Moderator
  • Hi Cindy Meister,

    Thank you for your sample coding.

    I did tried it out and it generates this error message:

    Error #1 The best overloaded method match for 'Word._Application.InchesToPoints(float)' has some invalid arguments        

    Error # 2 Argument '1': cannot convert from 'double' to 'float'    

    These are the C#NET2008  coding that causes the error message:

      private Word.Application objWord;

      private Word.Document objDoc;

     

      //--declare and instantiate WORD object      

      objWord = new Word.Application();

      objDoc = new Word.Document();

                           

     

     objDoc.PageSetup.FooterDistance = objWord.InchesToPoints(0.1); < - - error

     


    Thank you very Much, Have a Good Day. Cheers, Lennie
    Tuesday, January 4, 2011 10:34 AM
  • To make a value specifically of type float in C#, simply add the character f after the number: (0.1f)
    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Tee Leong Tuesday, January 4, 2011 11:22 PM
    Tuesday, January 4, 2011 4:32 PM
    Moderator
  • Hullo Wonderfu Cindy.

    Thank you for the solution sample coding. I have tried it out and it's working.

    There are two logically coding

    I tried this and it works too

    objWord.ActiveDocument.PageSetup.FooterDistance = 5;

    I tried out your contribution and it works too

    objDoc.PageSetup.FooterDistance = objWord.InchesToPoints(0.1f);

     

     

     


    Thank you very Much, Have a Good Day. Cheers, Lennie
    Tuesday, January 4, 2011 11:25 PM
  • Hi Lennie

    The difference in the two approaches you show is that mine specifically sets which measurement system to use. In your original quesiton you did specify .1 inches. If you need to specify in inches, you need to use InchesToPoints.

    If you know the value in Points, then you can certainly use the other line of code.


    Cindy Meister, VSTO/Word MVP
    Wednesday, January 5, 2011 1:27 PM
    Moderator