A little help with managing Microsoft Word from within a Lazarus program lazarus / 67-Windows ---------------------------------------------------------------------- EganSolo · 2017-10-22 23:43 I have a Windows specific request. I need to: Open a word document -- Done, know how to do thatSearch for a specific string and move the cursor in Word to that location.I know how to accomplish 1. I'm stumped with 2. Here's what I know: The Document object in Word has a Selection[//tt] object. In turn, Selection has a Find object which can be used to search. Find, according to this article on msdn.microsoft.com, requires the following parameters: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i With Selection.Find  .Forward = True  .ClearFormatting  .MatchWholeWord = True  .MatchCase = False  .Wrap = wdFindContinue  .Execute FindText:="Microsoft" End With  Question: How do I turn this VBA code into a pascal code relying on variants?. I'm facing at least two challenges with the faulty code below: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   fSelection := fDocument.Selection;  With fSelection.Find do  begin     Forward := True               ; //<== Won't compile     ClearFormatting               ;     MatchWholeWord := True        ;   MatchCase := False             ;     Wrap := wdFindContinue         ;     Execute FindText:="Microsoft" ; //<== won't compile.  end;  Any suggestion you might have here would be helpful. Also, As I go, I'm building a set of classes to wrap all this wonderful code behind a streamlined facade. If anyone is interested, let me know and I'll post it back here. Thanks ---------------------------------------------------------------------- engkin · 2017-10-23 03:54 Just guessing, how about: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   W := CreateOLEObject('Word.Application');  S := W.Selection;  F := S.Find;  //With fSelection.Find do  begin     F.Forward := True               ;     F.ClearFormatting               ;     F.MatchWholeWord := True      ;     F.MatchCase := False             ;     F.Wrap := wdFindContinue         ;     F.Execute(FindText := 'Microsoft');  end; ---------------------------------------------------------------------- EganSolo · 2017-10-25 04:32 So, yeah, that's not going very well ... Here's my latest attempt: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function TaiWordDocument.GoToText(const aText: String): Boolean;var C,F   : Variant;    WText : Variant;begin//  C := fDocument.Content       ;  C := fDocument.Range(0 , 0);  F := C.Find                  ;  F.Forward      := True     ;  F.ClearFormatting            ;  F.Highlight      := true     ;  F.MatchWholeWord := false    ;  F.MatchCase      := False    ;  F.Wrap           := wdFindContinue;  wText            := aText    ;  Result := F.Execute({FindText         } wText      ,                    {MatchCase        } EmptyParam ,                      {MatchWholeWord   } EmptyParam ,                      {MatchWildcards } EmptyParam ,                      {MatchSoundsLike  } EmptyParam ,                      {MatchAllWordForms} EmptyParam ,                    {Forward          } EmptyParam ,                      {Wrap           } EmptyParam ,                      {Format           } EmptyParam ,                      {ReplaceWith      } EmptyParam ,                    {Replace          } EmptyParam ,                      {MatchKashida     } EmptyParam ,                      {MatchDiacritics  } EmptyParam ,                      {MatchAlefHamza   } EmptyParam ,                      {MatchControl     } EmptyParam                     );  //F.Execute(FindText := wText  );end;  The method returns true but Microsoft Word does not move its focus to the string I'm searching. There's no difference if I use content or range. If anyone else has an idea, would be happy to consider it.