关于excel vba代码图片与楕圆框群组一问

关于excel vba代码一问
想请教,当我执行代码之后
要让图片和产生的图形楕圆框做群组,要怎么做修改???
请大哥大姐们帮忙看一下,谢谢您~假日愉快

Sub InsertPictureWithRedOvalInGColumn()    Dim ws As Worksheet    Dim pic As Picture    Dim picPath As Variant    Dim fd As FileDialog    Dim rng As Range    Dim targetCell As Range    Dim foundCell As Boolean        Set ws = ThisWorkbook.Worksheets("Sheet1")        Set fd = Application.FileDialog(msoFileDialogFilePicker)    With fd        .AllowMultiSelect = True        .Title = "选择图片"        .Filters.Add "图片档案", "*.jpg; *.jpeg; *.png; *.gif"                If .Show = -1 Then            For Each picPath In .SelectedItems                Set rng = ws.Range("G3:G" & ws.Cells(ws.Rows.Count, "G").End(xlUp).Row)                                Set targetCell = rng.Cells(3)                                foundCell = False                For Each pic In ws.Pictures                    If Not Intersect(pic.TopLeftCell, targetCell) Is Nothing Then                                              Set targetCell = targetCell.Offset(1)                    End If                Next pic                                  Set pic = ws.Pictures.Insert(picPath)                                pic.shapeRange.LockAspectRatio = msoFalse                pic.Width = targetCell.Width                pic.Height = targetCell.Height                                pic.Top = targetCell.Top                pic.Left = targetCell.Left                                Dim ovalWidth As Double                Dim ovalHeight As Double                ovalWidth = pic.Width / 2                ovalHeight = pic.Height / 2                Dim oval As Shape                Set oval = ws.shapes.AddShape(msoShapeOval, pic.Left + (pic.Width - ovalWidth) / 2, _                    pic.Top + (pic.Height - ovalHeight) / 2, ovalWidth, ovalHeight)                oval.Fill.Visible = msoFalse                oval.Line.ForeColor.RGB = RGB(255, 0, 0)                                Set targetCell = targetCell.Offset(1)            Next picPath        Else            Exit Sub        End If    End WithEnd Sub

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章