C# word图片格式设置问题。

问题描述:代码中设置图片为嵌入型,但是生成word之后图片没有格式。

代码:object range = wordApp.Selection.Range; ;//wordDoc.Paragraphs.Last.Range;
object linkToFile = false; //默认
object saveWithDocument = true; //默认
string dir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
InlineShape inlineShape = wordDoc.InlineShapes.AddPicture(dir + "\test.jpg", ref linkToFile, ref saveWithDocument, ref range);//向文档中插入图片

        Shape cShape = inlineShape.ConvertToShape();
        cShape.WrapFormat.Type = WdWrapType.wdWrapInline;
        Logging("Test.txt", "105", cShape.WrapFormat.Type.ToString());
        wordApp.Selection.ParagraphFormat.Alignment = WdParagraphAlignment.wdAlignParagraphCenter;
        wordApp.Selection.EndKey(6, 0);

结果:日志中Logging("Test.txt", "105", cShape.WrapFormat.Type.ToString());记录的是wdWrapNone。
目前测试了5台机器,只有一台会出现这个问题,求大佬们发表一下高见。

大召唤术,出来吧@CSDN的大佬们

大佬们呢,自己顶一下

我也碰到过,有时会报错。