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

Posted on 2009-02-16
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;
       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 ?
Question by:Josir
    LVL 36

    Accepted Solution

    in the related question it looks like this:
    MSWord.Selection.Style := 'NumeroQuestao';

    Author Comment

    Thank you Geert. It was simpler than I expected.

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    Suggested Solutions

    Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
    Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
    This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
    This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now