如何使用 VBA 将边框应用于 Excel sheet 中作为图片元素(Dim var as Picture)插入的图像?
How to apply border to images inserted as Picture elements (Dim var as Picture) in Excel sheet using VBA?
我想使用以下变量对插入到 excel sheet 中的图像应用边框:Dim Pic as Picture
来自本地目录(在此处下载后。)
我尝试在许多网站上搜索在线帮助,但没有任何帮助,因为大多数都是针对 Shape 变量而不是 Picture 变量。
我是否也必须使用 shape 变量,或者有没有办法在我输入 "Pic." 时应用边框,然后我可以看到可用的 Pic.border 选项,但我没有知道如何使用它。请对此提供帮助。
.....
URLDownloadToFile 0, imgsrc, dlpath & code + ".jpg", 0, 0
Dim PicPath As String, Pic As Picture, ImageCell As Range
PicPath = dlpath & unique_code & ".jpg"
Set ImageCell = Cells(i, "C").MergeArea
Set Pic = ActiveSheet.Pictures.Insert(PicPath)
Rows(i).RowHeight = 160
With Pic
.ShapeRange.LockAspectRatio = msoTrue
.Left = ImageCell.Left
.Top = ImageCell.Top
.Width = ImageCell.Width
.Height = ImageCell.Height
End With
.....
需要为这些图像应用边框。
我想用细边框包围图片。截至目前,它们覆盖了它们所属的单元格的边界
要添加宽度为 1 的边框,请按如下方式修改 With
代码部分:
With Pic
.ShapeRange.LockAspectRatio = msoTrue
With .ShapeRange.Line
.Visible = msoTrue
.Weight = 1
End With
.Left = ImageCell.Left
.Top = ImageCell.Top
.Width = ImageCell.Width
.Height = ImageCell.Height
End With
您可以在嵌套的 With
.
中添加任何其他边框参数
我想使用以下变量对插入到 excel sheet 中的图像应用边框:Dim Pic as Picture
来自本地目录(在此处下载后。)
我尝试在许多网站上搜索在线帮助,但没有任何帮助,因为大多数都是针对 Shape 变量而不是 Picture 变量。
我是否也必须使用 shape 变量,或者有没有办法在我输入 "Pic." 时应用边框,然后我可以看到可用的 Pic.border 选项,但我没有知道如何使用它。请对此提供帮助。
.....
URLDownloadToFile 0, imgsrc, dlpath & code + ".jpg", 0, 0
Dim PicPath As String, Pic As Picture, ImageCell As Range
PicPath = dlpath & unique_code & ".jpg"
Set ImageCell = Cells(i, "C").MergeArea
Set Pic = ActiveSheet.Pictures.Insert(PicPath)
Rows(i).RowHeight = 160
With Pic
.ShapeRange.LockAspectRatio = msoTrue
.Left = ImageCell.Left
.Top = ImageCell.Top
.Width = ImageCell.Width
.Height = ImageCell.Height
End With
.....
需要为这些图像应用边框。
我想用细边框包围图片。截至目前,它们覆盖了它们所属的单元格的边界
要添加宽度为 1 的边框,请按如下方式修改 With
代码部分:
With Pic
.ShapeRange.LockAspectRatio = msoTrue
With .ShapeRange.Line
.Visible = msoTrue
.Weight = 1
End With
.Left = ImageCell.Left
.Top = ImageCell.Top
.Width = ImageCell.Width
.Height = ImageCell.Height
End With
您可以在嵌套的 With
.