Excel 2007参考图像以编程方式隐藏/重现它

在这里完成Excel 2007或VBA脚本的noob …

我需要以编程方式select一些图像(实际上它们都是相同的图像)并隐藏它们,或者如果不可能的话,在工作表的特定位置重现固定图像…

要显示的图像的数量由一些行的范围的计数控制,如果该范围内的某一行充满数据,则必须显示一个图像,否则,该图像将不会显示…这是在另一张文件上完成的…

有没有办法做到这一点?

这是我用的:

' Manages Images in Img worksheet, according to values captured at Ref worksheet ' Ref = worksheet to know if image is to be displayed, ' Cells Ax are empty when we're not displaying image or else it'll be displayed ' Img = worksheet for the images, each image is named 'Picture x' ' N = Max amount of images to show/hide Public Function ManImages(ByVal N As Integer, _ ByVal Ref As Integer, ByVal Img As Integer) Set ref = Worksheets(Ref) For x = 1 To N If ref.Range("A" & x) <> "" Then a = HideImage(x, False, Img) Else a = HideImage(x, True. Img) End If Next x End Sub ' Hides or Shows images by index according to fixed name of the shapes ' ind is the image to manage ' st is True to show, False to hide ' Img is the worksheet where the images live Public Function HideImage(ByVal ind As Integer, ByVal st As Boolean, ByVal Img As Integer) As String Set doc = Worksheets(Img) doc.Shapes("Picture " & ind).Visible = st HideImages = st End Function