首页 > 解决方案 > 带有图像的 VBA 价格表:TopLeftCell 给出了错误的地址

问题描述

大家 好,我正在创建内衣店。我在 excel 文件中有价目表,并试图获取如下图像:

我的 Excel 文件

我正在使用找到Excel VBA 的解决方案:如何检查单元格内的图片名称? 我稍微修改了代码:

Sub CheckImageName()
Dim pic                   As Excel.Picture


For Each pic In ActiveSheet.Pictures


    'pic.Top = pic.Top + 20
    'pic.Left = pic.Left + 20
   pic.TopLeftCell.Value = pic.Name






Next pic
end sub

同时我已经打开 XLSX 作为 ZIP 端从工作表中获取所有图像。

问题是,单元格中的图像名称与图像内容不对应。在选定的情况下 image279.jpg 是:

我的 Excel 文件

我做错了什么?

标签: excelvba

解决方案


Tomasz, I see from your first screenshot that image279.jpg is actually stored in the cell's value (B281), instead of the picture's name itself.

enter image description here

Here's where you should store your picture's name in order to make your code work (select the picture > name box in the top-left corner):

enter image description here


推荐阅读