Interop Word Add Shape Giving Исключение - открытый член 'Shapes' для типа 'ApplicationClass' не найден - PullRequest
0 голосов
/ 07 ноября 2019

Я добавляю изображение в файл слова и нашел одно решение. Когда я реализовал это решение для моего кода. Я даю System.MissingMemberException: открытый член 'Shares' для типа 'ApplicationClass' не найден.

    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()

Спасибо.

1 Ответ

0 голосов
/ 07 ноября 2019

Свойство 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()
...