0
我用下面的代碼的形狀(矩形)插入到Word文檔,Word VSTO - 在光標點插入形狀?
Dim oShpWidth As Single
Dim oShpHght As Single
Dim oShpTop As Single
Dim oShpLeft As Single
With Globals.ThisAddIn.Application.ActiveDocument
oShpWidth = 225.1
oShpHght = 224.5
oShpTop = 0
oShpLeft = 0
.Shapes.AddShape(1, 0, 0, oShpWidth, oShpHght).Select()
With Globals.ThisAddIn.Application.Selection.ShapeRange
.Rotation = 0.0#
.RelativeHorizontalPosition = Word.WdRelativeHorizontalPosition.wdRelativeHorizontalPositionCharacter
.RelativeVerticalPosition = Word.WdRelativeVerticalPosition.wdRelativeVerticalPositionLine
.Left = oShpTop
.Top = oShpLeft
End With
End With
但是,這增加了形狀到當前頁面的頂部。我想在光標點添加形狀。怎麼做?
謝謝[查理] (http://stackoverflow.com/users/4923873/charlie)。但此代碼Word.InlineShape shape = app.Selection.InlineShapes.AddPicture(@「C:\ Users \ Public \ Pictures \ Sample Pictures \ Koala.jpg」,false,true,Type.Missing);'僅適用於添加圖片對象。它不適用於像矩形一樣的形狀。你知道如何修改這個在光標點添加形狀嗎? –
太棒了!完美工作。 –
[查理](http://stackoverflow.com/users/4923873/charlie),請檢查這個問題:[字VSTO - 填充形狀不適用於Word 2010和Word 2013?](http:// stackoverflow .COM /問題/ 31589137 /字VSTO填充-A-形狀不 - 不工作在字2010和字-2013)。提前致謝。 –