Freelance Project Requests info@CodeDocu.de Software Development in C# WPF Asp.Net Core Vba Excel Word SQL-Server EF Linq, UWP Net
#

Word: insert characters at the end of a line

 

This little code script inserts a break at the end of a sentence and then inserts an empty table.

 

In C #, according to vba

sLine.InsertAfter("\r\r");

            sLine.Select();

            _app.Selection.EndKey();

            _app.Selection.Select();

            Range newRange = _app.Selection.Range;

            _app.ScreenRefresh();

            

            //< create new table >

            Word.Table newTable = _doc.Tables.Add( newRange ,NumRows:1,NumColumns: 2);

            //</ create new table >

 

 

 

Subject: vba macro, c # intercom vsto

 

 

Complete code snippet, example

private Word.Table find_Textline_Create_Empty_Table(string sHeader)

{

    //-----------------< find_Table_with_Header() >-----------------

 

 

    //--< find Table Header >--

    //*Loop all tables and look for header

    foreach (Word.Range sLine in _doc.Sentences)

    {

        //-------< Check Sentence >------

        string sText = sLine.Text;

 

        sText = sText.Trim();

        if (sText == sHeader )

        {

            //----< Line_found >----

            

            sLine.InsertAfter("\r\r");

            sLine.Select();

            _app.Selection.EndKey();

            _app.Selection.Select();

            Range newRange = _app.Selection.Range;

            _app.ScreenRefresh();

 

            //< init setup >

            int Columns_Count = Settings1.Default.Columns_Count;

            //</ init setup >

 

            //< create new table >

            //Word.Range newRange = sLine.MoveEnd(WdUnits.wdCharacter, -1);

            Word.Table newTable = _doc.Tables.Add( newRange ,NumRows:1,NumColumns: Columns_Count);

            newTable.Borders.InsideColor = WdColor.wdColorRed;

            //</ create new table >

 

            //< out >

            return newTable;

            //</ out >

            //----</ Line_found >----

        }

        //-------</ Check Sentence >------

    }

    //< check >

    System.Windows.Forms.MessageBox.Show("Zeile nicht gefunden. " + Environment.NewLine + "gesuchter Header:" + sHeader, "Header nicht gefunden");

    return null;

    //--</ find Table Header >--

    //-----------------</ find_Table_with_Header() >-----------------

}

 

 

 

 

 

 

 

 

Mobile
vba
»
Insert a line break at the end of a line and then insert text or a table
»
Word: insert characters at the end of a line
»
Text input fields in Word with vba c #
»
Create input fields in Word. C# ContentControls
»
Protect Word programmatically
»
Word vba: find current sentence
»
Word vba: Change document property title dynamically with Textbox Control
»
Word Code: Edit photos and controls in vba
»
Word: Find vba Code Example
»
Word vba macro: Changing WordArt with glow effect and shadow

.

Contact for Jobs, Project Requests: raimund.popp@microsoft-programmierer.de