Fix Picture Wrapping in Word Interop with C#
Question details
Set square text wrapping for a picture inserted through C# Word Interop.

- 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.
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.
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.
In your C# code, add the picture to the content control's range: Word.InlineShape inlineShape = contentControl.Range.InlineShapes.AddPicture(path);
Convert the inserted picture and use the returned object: Word.Shape shape = inlineShape.ConvertToShape(); shape.WrapFormat.Type = Word.WdWrapType.wdWrapSquare;
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.

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.

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.




