How to Create WordArt in Word in C#, VB.NET

Spire.Doc included a variety of WordArt types in the ShapeType enum. In order to create WordArt in Word, initialize an instance of ShapeObject and specify the WordArt type and content. The following sections show you how to create WordArt using Spire.Doc step by step.

Step 1: Create an instance of Document class.

Document doc = new Document();

Step 2: Add a section, add a paragraph in section.

Section section = doc.AddSection();
Paragraph paragraph = section.AddParagraph();

Step 3: Create a ShapeObject instance and specify TextWave4 as the ShapeType. Specify the content of WordArt.

ShapeObject shape= paragraph.AppendShape(120, 30, ShapeType.TextWave4);
shape.WordArt.Text = "Thanks for reading.";

Step 4: Set the position, fill color and stroke color of the shape (WordArt).

shape.VerticalPosition = 80;
shape.HorizontalPosition = 170;
shape.FillColor = System.Drawing.Color.Red;
shape.StrokeColor = System.Drawing.Color.Yellow;

Step 5: Save the file.

doc.SaveToFile("output.docx", FileFormat.Docx2013);

Output:

How to Create WordArt in Word in C#, VB.NET

Full Code:

[C#]
Document doc = new Document();
Section section = doc.AddSection();
Paragraph paragraph = section.AddParagraph();

ShapeObject shape= paragraph.AppendShape(120, 30, ShapeType.TextWave4);
shape.VerticalPosition = 80;
shape.HorizontalPosition = 170;
shape.WordArt.Text = "Thanks for reading.";
shape.FillColor = System.Drawing.Color.Red;
shape.StrokeColor = System.Drawing.Color.Yellow;

doc.SaveToFile("output.docx", FileFormat.Docx2013);
[VB.NET]
Dim doc As New Document()
Dim section As Section = doc.AddSection()
Dim paragraph As Paragraph = section.AddParagraph()

Dim shape As ShapeObject = paragraph.AppendShape(120, 30, ShapeType.TextWave4)
shape.VerticalPosition = 80
shape.HorizontalPosition = 170
shape.WordArt.Text = "Thanks for reading."
shape.FillColor = System.Drawing.Color.Red
shape.StrokeColor = System.Drawing.Color.Yellow

doc.SaveToFile("output.docx", FileFormat.Docx2013)