Link to home
Start Free TrialLog in
Avatar of Josir
JosirFlag for Brazil

asked on

How to apply a pre-formated Style using Delphi Word Automation

In VBA/Macro, I can do this with the following command:

    Selection.Style = ActiveDocument.Styles("NumeroQuestao")

How can I do the same with Delphi ?

  MSWord := CreateOleObject('Word.Application');
  MSWord.Visible := true;
  try
       ProvaDOC := MSWord.Documents.Add( 'prova.dotx' );
       ProvaDOC.Paragraphs.Last.Range.Select;
       MSWord.Selection.Style := ProvaDoc.Styles('NumeroQuestao');

But I got a runtime error on the last line: "Item is not a property"

Does someone know the correct translation to a Delphi syntax ?
ASKER CERTIFIED SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Josir

ASKER

Thank you Geert. It was simpler than I expected.