Recent

Author Topic: [SOLVED] Select a paragraph in Microsoft Word  (Read 263 times)

w click

  • Full Member
  • ***
  • Posts: 161
[SOLVED] Select a paragraph in Microsoft Word
« 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.)
« Last Edit: June 26, 2022, 05:46:53 pm by w click »

w click

  • Full Member
  • ***
  • Posts: 161
Re: Select a paragraph in Microsoft Word
« Reply #1 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.

cpicanco

  • Sr. Member
  • ****
  • Posts: 468
  • Programmer and Behavioral Scientist
    • Portfolio
Re: [SOLVED] Select a paragraph in Microsoft Word
« Reply #2 on: June 26, 2022, 06:04:28 pm »
What package are you using for Microsoft Word automation?

w click

  • Full Member
  • ***
  • Posts: 161
Re: [SOLVED] Select a paragraph in Microsoft Word
« Reply #3 on: June 26, 2022, 06:44:44 pm »
It's OK, cpicanco, I solved it.  Cheers.

 

TinyPortal © 2005-2018