We help IT Professionals succeed at work.

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

Josir
Josir asked
on
Medium Priority
369 Views
Last Modified: 2012-05-06
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 ?
Comment
Watch Question

Oracle dba
CERTIFIED EXPERT
Top Expert 2009
Commented:
in the related question it looks like this:
MSWord.Selection.Style := 'NumeroQuestao';

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thank you Geert. It was simpler than I expected.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.