Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在excel/VBA中获取活动对象(图像)的范围_Excel_Vba_Range - Fatal编程技术网

在excel/VBA中获取活动对象(图像)的范围

在excel/VBA中获取活动对象(图像)的范围,excel,vba,range,Excel,Vba,Range,我知道这是难以置信的简单,我只是似乎无法找出它或在别处找到答案。我要做的就是获取所选图像的范围。提前感谢你的帮助 这里是如何在excel工作表上获取图片左上角和右下角单元格的示例。必须选择图片 Sub test() If (VBA.TypeName(Selection) = "Picture") Then Dim pic As Excel.Picture Set pic = Selection Dim topLeft As Range

我知道这是难以置信的简单,我只是似乎无法找出它或在别处找到答案。我要做的就是获取所选图像的范围。提前感谢你的帮助

这里是如何在excel工作表上获取图片左上角和右下角单元格的示例。必须选择图片

Sub test()
    If (VBA.TypeName(Selection) = "Picture") Then
        Dim pic As Excel.Picture
        Set pic = Selection

        Dim topLeft As Range
        Set topLeft = pic.TopLeftCell
        Debug.Print topLeft.Address

        Dim bottomRight As Range
        Set bottomRight = pic.BottomRightCell
        Debug.Print bottomRight.Address
    End If
End Sub

图像和范围在Excel中是不同的对象。你能更具体一点你想做什么吗?谢谢你,丹,这正是我需要的!