An example of text selection "from" and "to" lines is seen, but "from" and "to the end" is required

W.ActiveDocument.Range(Start := 10, End := 40).Select; 

    2 answers 2

    If "to the end" = "to the very end":

     Procedure SelectFromPositionToEnd(startPosition: integer); begin W.Selection.Start := startPosition; W.Selection.End := W.ActiveDocument.Characters.Count; // последний символ в документе end; 

    If "to the end" = "to the end of the sentence":

     Procedure SelectFromPositionToEdnOfSentence(startPosition: integer); const WdSentence = 3; //значение для перехода к следующему предложению begin w.Selection.Start := startPosition; //поставили сюда курсор w.Selection.Move(WdSentence, 1); //передвинули до следующего предложения w.Selection.Start := startPosition; //растянули выделение до начального символа end; 

    If "to the end" = "to the end of the line", then the same as in the second case, just replace the first parameter in Move with

     WdSentence 

    on

     Wdline = 5 //значение для перехода к следующей линии (строке) 
       Selection.EndKey Unit:=wdStory, Extend:=wdExtend 
      • Is it instead of 40 to add? - Makine
      • one
        Please try to leave a little more detailed answers. - aleksandr barakin
      • @Makine No, add DIRECTLY AFTER. And the selection is not in lines, but in characters. - Akina
      • one
        The syntax is really not delphi ... who can translate into delphi? - Makine
      • one
        There is a simple principle. You need to write a macro in the Word and see the contents. Well, and then stupidly call functions to google, what was done and how. In different languages ​​there are completely different examples, you can find it on delphi. - Albert Fomin