Lazarus

Programming => General => Topic started by: w click on June 26, 2022, 04:48:54 pm

Title: [SOLVED] Select a paragraph in Microsoft Word
Post by: w click on June 26, 2022, 04:48:54 pm
Another Microsoft Word automation problem.

I want to do this to select a target paragraph.  Target is an integer and I'm using Windows.
Code: Pascal  [Select][+][-]
  1. wordapp.paragraphs(target).range.select;
I get 'Method 'paragraphs' is not supported by automation object'.  So, er, what do I do?
(In fact, I don't need to select the paragraph, if I can move the cursor to the target paragraph.)
Title: Re: Select a paragraph in Microsoft Word
Post by: w click on June 26, 2022, 05:46:09 pm
You idiot, w click.  Use sourcedoc!!!
Code: Pascal  [Select][+][-]
  1. sourcedoc.paragraphs(target).range.select;
  2.  
When you've opened it with
Code: Pascal  [Select][+][-]
  1.     try
  2.       try
  3.         WordApp:=CreateOleObject('Word.Application');
  4.       except
  5.         showmessage('Unable to start Word.');
  6.       end;
  7.       sourcedoc:=wordapp.Documents.Open(WideString(utf8decode(s)));
  8.       WordApp.Visible:=True;  {Make WordApp visible}
  9.     except
  10.       showmessage('It all went pear-shaped.');
  11.     end;
  12.  
  13.  
I mean, for goodness sake.
Title: Re: [SOLVED] Select a paragraph in Microsoft Word
Post by: cpicanco on June 26, 2022, 06:04:28 pm
What package are you using for Microsoft Word automation?
Title: Re: [SOLVED] Select a paragraph in Microsoft Word
Post by: w click on June 26, 2022, 06:44:44 pm
It's OK, cpicanco, I solved it.  Cheers.
TinyPortal © 2005-2018