Excel"无法获得图片类的高度属性"

时间:2017-06-09 17:44:13

标签: excel vba excel-vba

我在工作簿中使用以下代码

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)   
 Dim MyPicture As Object    
Dim MyTop As Double    
Dim MyLeft As Double    
Dim BottomRightCell As Range

'-----------------------------------------------------------

   '- bottom right cell 
   With ActiveWindow.VisibleRange 
       r = .Rows.Count 
       c = .Columns.Count 
       Set BottomRightCell = .Cells(r, c) 
   End With

   '------------------------------------------------------------

   '- position picture 
   Set MyPicture = ActiveSheet.Pictures(1) 
   MyTop = BottomRightCell.Top - MyPicture.Height - 5 
   MyLeft = BottomRightCell.Left - MyPicture.Width - 5

   With MyPicture 
       .Top = MyTop 
       .Left = MyLeft 
   End With

End Sub

我收到错误"无法获取图片类的高度属性"而且我不知道为什么。

我在其他工作表中使用了相同的代码并且有效。

有什么想法吗?

0 个答案:

没有答案