Getting a word out of MS Word lazarus / 34-Windows ---------------------------------------------------------------------- w click · 2021-09-24 10:37 I'm trying to pass the word under the cursor from Microsoft Word to a program. I'm using olevariants and gone with the following:-    WordApp:=CreateOleObject('Word.Application');    sourcedoc:=wordapp.Documents.Open(WideString(utf8decode(filename))); And Word opens up fine.  Now I want to do something like:-    label1.caption:=sourcedoc.WordUnderTheCursor; I've tried all sorts of things, but I've simply not hit upon the magic word.  I am getting 'Incompatible type for arg no. 1: Got "OleVariant", expected "TTranslateString" when I tried 'sourcedoc.selection.text' and other wild experiments. Can anyone help, please? ---------------------------------------------------------------------- PascalDragon · 2021-09-24 11:34 Did you try the following? 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 label1.caption := WideString(sourcedoc.WordUnderTheCursor); ---------------------------------------------------------------------- Jurassic Pork · 2021-09-24 12:26 hello, WordUnderTheCursor does'nt exist and Selection applies to application not document. Try : 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 label1.caption := WideString(WordApp.Selection.Text); Friendly, J.P ---------------------------------------------------------------------- w click · 2021-09-24 13:11 Pascal Dragon: Yep, tried that ;-) Jurassic Pork: that does the trick - thanks. Except to be really clever I need to highlight the word.  I have to double click the word, otherwise I just get the letter the cursor is on.  Do you know the magic code to do an automatic double click, word highlight or whatever?