gpt4 book ai didi

vba - Excel 2007 引用图像以编程方式隐藏/复制它

转载 作者:行者123 更新时间:2023-12-02 22:14:13 25 4
gpt4 key购买 nike

这里是 Excel 2007 或 VBA 脚本的新手...

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

显示的图像数量由某个范围的行数控制,如果该范围内的某行已充满数据,则必须显示一张图像,如果没有,则不会显示该图像...这是在文档的另一张纸上完成的...

有什么办法可以实现这一点吗?

最佳答案

这是我使用的:

' 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

关于vba - Excel 2007 引用图像以编程方式隐藏/复制它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9383167/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com