我正在将图像添加到Word文件中,并且找到了一种解决方案。当我对我的代码实施该解决方案时。我正在给System.MissingMemberException:找不到类型为'ApplicationClass'的公共成员'Shares'。
Dim autoScaledInlineShape As InlineShape = wordApp.Selection.InlineShapes.AddPicture(strImageFileName)
Dim scaledWidth As Single = autoScaledInlineShape.Width
Dim scaledHeight As Single = autoScaledInlineShape.Height
autoScaledInlineShape.Delete()
Dim newShape As Microsoft.Office.Interop.Word.Shape = wordApp.Shapes.AddShape(1, 0, 0, scaledWidth, scaledHeight)
newShape.Fill.UserPicture(strImageFileName)
Dim finalInlineShape As InlineShape = newShape.ConvertToInlineShape()
finalInlineShape.Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse
finalInlineShape.Range.Cut()
wordApp.Selection.Paste()
谢谢。
答案 0 :(得分:0)
Shapes属性属于Document
类,而不是Word Application
类。
Dim autoScaledInlineShape As InlineShape = wordApp.Selection.InlineShapes.AddPicture(strImageFileName)
Dim scaledWidth As Single = autoScaledInlineShape.Width
Dim scaledHeight As Single = autoScaledInlineShape.Height
autoScaledInlineShape.Delete()
Dim newShape As Microsoft.Office.Interop.Word.Shape = wordApp.ActiveDocument.Shapes.AddShape(1, 0, 0, scaledWidth, scaledHeight)
newShape.Fill.UserPicture(strImageFileName)
Dim finalInlineShape As InlineShape = newShape.ConvertToInlineShape()
finalInlineShape.Line.Visible = Microsoft.Office.Core.MsoTriState.msoFalse
finalInlineShape.Range.Cut()
wordApp.Selection.Paste()