none
Textbox in footer RRS feed

  • Question

  • I am working on Office.Interop.Word using c#. I have a simple winform and has a button and all this button does,  place the name of the document at the footer. 

    Can I add a textbook with certain text in the footer  and not affecting existing footer and their style. 


    Friday, June 22, 2018 2:55 AM

Answers

  • Hello, 

    As far as I know, insert a text box will not be conflict with existing footer style. What you need to do is just add a shape in the footer range and it does not change the footer's style.

    Here is the sample code.

    Word.HeaderFooter footer = oDoc.Sections[1].Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary];
                Word.Shape textBoxShape=
                    footer.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 
                    footer.Range.Information[Word.WdInformation.wdHorizontalPositionRelativeToPage],
                    footer.Range.Information[Word.WdInformation.wdVerticalPositionRelativeToPage],
                    200, 
                    20);
                textBoxShape.TextFrame.TextRange.Text = "This is an inserted Text Box";

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by newbiesaspnet Friday, June 22, 2018 5:58 PM
    • Unmarked as answer by newbiesaspnet Monday, June 25, 2018 3:13 PM
    • Marked as answer by newbiesaspnet Monday, June 25, 2018 3:38 PM
    Friday, June 22, 2018 7:50 AM

All replies

  • Hello, 

    As far as I know, insert a text box will not be conflict with existing footer style. What you need to do is just add a shape in the footer range and it does not change the footer's style.

    Here is the sample code.

    Word.HeaderFooter footer = oDoc.Sections[1].Footers[Word.WdHeaderFooterIndex.wdHeaderFooterPrimary];
                Word.Shape textBoxShape=
                    footer.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 
                    footer.Range.Information[Word.WdInformation.wdHorizontalPositionRelativeToPage],
                    footer.Range.Information[Word.WdInformation.wdVerticalPositionRelativeToPage],
                    200, 
                    20);
                textBoxShape.TextFrame.TextRange.Text = "This is an inserted Text Box";

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by newbiesaspnet Friday, June 22, 2018 5:58 PM
    • Unmarked as answer by newbiesaspnet Monday, June 25, 2018 3:13 PM
    • Marked as answer by newbiesaspnet Monday, June 25, 2018 3:38 PM
    Friday, June 22, 2018 7:50 AM
  • Hi Terry, do you know why this is not working for Different First Page ? Thanks
    Monday, June 25, 2018 4:55 PM