Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

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;
       ProvaDOC := MSWord.Documents.Add( 'prova.dotx' );
       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 ?
1 Solution
Geert GruwezOracle dbaCommented:
in the related question it looks like this:
MSWord.Selection.Style := 'NumeroQuestao';
JosirAuthor Commented:
Thank you Geert. It was simpler than I expected.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now