而不是隱藏/移動/減少不需要的圖片的大小,爲什麼不簡單地刪除它?
邏輯: 將所有圖像保存在臨時工作表中。如果有相關圖片應該顯示,請從臨時表中取出並刪除前一張。
這裏是一個例子。
Sub Sample()
Select Case Range("G11").Value
Case "Picture 1": ShowPicture ("Picture 1")
Case "Picture 2": ShowPicture ("Picture 2")
Case "Picture 3": ShowPicture ("Picture 3")
Case "Picture 4": ShowPicture ("Picture 4")
End Select
End Sub
Sub ShowPicture(picname As String)
'~~> The reason why I am using OERN is because it is much simpler
'~~> than looping all shapes and then deleting them. There could be
'~~> charts, command buttons and other shapes. I will have to write
'~~> extra validation code so that those shapes are not deleted.
On Error Resume Next
Sheets("Sheet1").Shapes("Picture 1").Delete
Sheets("Sheet1").Shapes("Picture 2").Delete
Sheets("Sheet1").Shapes("Picture 3").Delete
Sheets("Sheet1").Shapes("Picture 4").Delete
On Error GoTo 0
Sheets("Temp").Shapes(picname).Copy
'<~~ Alternative to the below line. You may re-position the image
'<~~ after you paste as per your requirement
Sheets("Sheet1").Range("G15").Select
Sheets("Sheet1").Paste
End Sub
快照溫度片
我沒有這樣做,但從來沒有想過,只是它縮小到什麼感謝的解決方案現在要嘗試 – 2012-02-08 17:35:33
對一個沒有運氣只允許一個圖像不能做多張圖片。我希望使用單元格值可以控制顯示的圖像 – 2012-02-08 17:52:47