gpt4 book ai didi

excel - 图片周围的VBA Excel边框

转载 作者:行者123 更新时间:2023-12-04 22:23:40 25 4
gpt4 key购买 nike

早上好,

精确我昨天的问题:
VBA Excel border around the specified picture

我想为我的 Excel 文档中的大多数图像制作自动边框。
我开始录制宏,如下所示:

  Sub Picbodred()
'
' Picbodred Macro
'

'
ActiveSheet.Shapes.Range(Array("Picture 2")).Select
With Selection.ShapeRange.Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 0)
.Transparency = 0
End With
End Sub

但它只涵盖 1 张图片,最糟糕的是,这张图片分配了 ID,这不会是相同的。
最重要的是,我想保留一些没有边框的图像,如下图所示:

enter image description here

我该怎么做?

最佳答案

实际上,让我把这个写成答案,嗨。

你如何命名所有你想要边框的图片: SomeName_Border 然后运行这个宏:

Sub test()

For i = 1 To ThisWorkbook.Sheets("sheetname").Shapes.Count

If ThisWorkbook.Sheets("sheetname").Shapes(i).Name Like "*Border" Then

With ThisWorkbook.Sheets("Sheetname").Shapes(i).Line
.Visible = msoTrue
.ForeColor.RGB = RGB(0, 0, 0)
.Transparency = 0
End With
End If

Next

End Sub

只需将宏记录器中的 .somethingsomething 更改为使用它记录的任何内容。如果您以后可能想要更粗的线条或其他东西,我的意思是。

关于excel - 图片周围的VBA Excel边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60111267/

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