C#/VB.NET: Insert WordArt in Word

WordArt is a feature in MS Word that allows you to insert colorful and stylish text into your document. Apart from that, it can also bend, stretch, or skew the shape of the text, which is a quick way to make the text stand out with special effects. In this article, you will learn how to programmatically insert WordArt in a Word document using Spire.Doc for .NET.

Install Spire.Doc for .NET

To begin with, you need to add the DLL files included in the Spire.Doc for .NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.Doc

Insert WordArt in Word

The ShapeType enumeration provided by Spire.Doc for .NET defines a variety of WordArt shape types whose names begin with "Text". In order to create a WordArt in Word, you need to initialize an instance of ShapeObject and specify the WordArt type and text content. The detailed steps are as follows:

  • Create a Document instance.
  • Add a section to the document using Document.AddSection() method, and then add a paragraph to the section using Section.AddParagraph() method.
  • Append a shape to the paragraph and specify the shape size and type using Paragraph.AppendShape(float width, float height, ShapeType shapeType) method.
  • Set the position of the shape using ShapeObject.VerticalPosition and ShapeObject.HorizontalPosition properties.
  • Set the text of WordArt using WordArt.Text property.
  • Set the fill color and stroke color of WordArt using ShapeObject.FillColor and ShapeObject.StrokeColor properties.
  • Save the document to another file using Document.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;
namespace CreatWordArt
    class Program
        static void Main(string[] args)
            //Create a Document instance
            Document doc = new Document();

            //Add a section
            Section section = doc.AddSection();

            //Add a paragraph
            Paragraph paragraph = section.AddParagraph();

            //Append a shape to the paragraph and specify the shape size and type
            ShapeObject shape = paragraph.AppendShape(400, 150, ShapeType.TextDeflateBottom);

            //Set the position of the shape
            shape.VerticalPosition = 60;
            shape.HorizontalPosition = 60;
            //Set the text of WordArt
            shape.WordArt.Text = "Create WordArt in Word";

            //Set the fill color and stroke color of WordArt
            shape.FillColor = System.Drawing.Color.Cyan;
            shape.StrokeColor = System.Drawing.Color.DarkBlue;

            //Save the document
            doc.SaveToFile("CreateWordArt.docx", FileFormat.Docx2013);

C#/VB.NET: Insert WordArt in Word

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.