求助:VBA代码哪里有问题。

weixin_47875022 weixin_47875022 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

各位老大

大家好。

我想把EXCEL单元格里的图片批量导出来,并且以人名来命名,写完的代码哪里有问题,拜托大家指导一下。

感谢。

Sub Rename()

Application.ScreenUpdating = False

On Error Resume Next

MkDir ThisWorkbook.Path & "\pho"

For Each pic In ActiveSheet.Shapes

    If pic.Type = msoPicture Then

        rn = pic.TopLeftCell.Offset(0, -1).Value

        pic.Copy

        With ActiveSheet.ChartObjects.Add(0, 0, pic.Width, pic.Height).Chart

            .Parent.Select

            .Paste

            .Export ThisWorkbook.Path & "\pho" & rn & ".jpg"

            .Parent.Delete

        End With

    End If

Next

MsgBox "导出图片完成!"

Application.ScreenUpdating = True

End Sub

...全文
评论 2
收藏 已收藏
分享
返回顶部
weixin_47875022
VBA 2,506 成员 10,830 内容