Formatting Issues

Fix Picture Wrapping in Word Interop with C#

Emma BrownEmma Brown Nov 22, 2026 869 views

Question details

Set square text wrapping for a picture inserted through C# Word Interop.

Fix Picture Wrapping in Word Interop with C#
Product
Microsoft Word Interop
Device & OS
not provided
Scenario
A C# application inserts a picture into a Word picture content control and needs text to wrap around it.
Observed behavior
The inserted picture uses In Line with Text wrapping, and accessing Selection.ShapeRange causes a COM exception.
Before you start

Check that the picture path is valid and that your C# project references the Microsoft Word interop library. Confirm that the picture's location supports a floating shape, since converting it may change its relationship to the content control.

Solution 1Recommended

Convert the inline picture to a floating shape

Use the shape returned by ConvertToShape to apply square wrapping without relying on the current selection.

An InlineShape always uses In Line with Text wrapping. Square wrapping is available on a floating Shape through its WrapFormat property.

1
Insert the picture

In your C# code, add the picture to the content control's range: Word.InlineShape inlineShape = contentControl.Range.InlineShapes.AddPicture(path);

2
Convert and set wrapping

Convert the inserted picture and use the returned object: Word.Shape shape = inlineShape.ConvertToShape(); shape.WrapFormat.Type = Word.WdWrapType.wdWrapSquare;

3
Verify the result

Run the code and inspect the picture in Word. Confirm that it has square wrapping and remains positioned as intended relative to the content control.

Convert the inline picture to a floating shape
Check the shape's location: Conversion to a floating shape may fail or alter how the picture is associated with a content control. If it does, consider placing the floating shape outside the control and anchoring it at an appropriate document range.
Free Microsoft Office alternative

Edit picture wrapping in WPS Writer

WPS Writer is a free, lightweight Office alternative with a familiar interface for editing documents and picture layouts. It supports Word formats for an easy transition, but it does not fix Microsoft Word Interop or its COM exceptions.

Adjust picture wrapping while editing a documentOpen and save Microsoft Word DOCX and DOC filesUse a familiar interface for common document tasksWork with a free, lightweight Office alternative
microsoft office alternative - wps office

Frequently Asked Questions

Why does my inserted picture use In Line with Text?

Pictures added through Range.InlineShapes.AddPicture are InlineShape objects, which always use In Line with Text. Call ConvertToShape and set the returned shape's WrapFormat.Type to wdWrapSquare for square wrapping.

Why does Selection.ShapeRange throw a COM exception?

The current selection may not contain a floating shape. Use the Shape returned by inlineShape.ConvertToShape() instead of assuming Selection.ShapeRange contains the inserted picture.

Can I keep a floating picture inside a picture content control?

Floating shapes may not remain associated with a picture content control as expected. Test the conversion in your document; if it fails or changes the layout, consider placing the shape outside the control and anchoring it at a suitable range.

Can WPS Office fix a Word Interop COM exception?

No. The exception concerns Microsoft Word's Interop object model. WPS Writer is an alternative for manually editing Word-compatible documents, not a fix for Word automation code.