如何让图像出现在给定图像 url 的 Excel 中 [英] How to get images to appear in Excel given image url

查看:29
本文介绍了如何让图像出现在给定图像 url 的 Excel 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个 csv 文件,其中一列包含图像的网址(例如,www.myDomain.com/myImage.jpg).
如何让 Excel 呈现此图像?

I'm creating a csv file with one of the columns containing an url of an image (e.g., www.myDomain.com/myImage.jpg).
How I can get Excel to render this image?

推荐答案

Dim url_column As Range
Dim image_column As Range

Set url_column = Worksheets(1).UsedRange.Columns("A")
Set image_column = Worksheets(1).UsedRange.Columns("B")

Dim i As Long
For i = 1 To url_column.Cells.Count

  With image_column.Worksheet.Pictures.Insert(url_column.Cells(i).Value)
    .Left = image_column.Cells(i).Left
    .Top = image_column.Cells(i).Top
    image_column.Cells(i).EntireRow.RowHeight = .Height
  End With

Next

<小时>

作为 Excel 行为 多年来 明显发生了变化,您可能希望为 Insert 调用明确指定更多参数:


As Excel behaviour has apparently changed over years, you might want to specify more parameters to the Insert call explicitly:

对于登陆这里的人.不同版本的 Excel 对这个请求的处理方式不同,Excel 2007 会将图片作为对象插入,即嵌入到工作簿中.Excel 2010 会将其作为链接插入,如果您打算将其发送给任何人,这将是糟糕的时期.您需要更改插入以指定它是嵌入的:Insert(Filename:= , LinkToFile:= False, SaveWithDocument:= True)

For people landing here. Different versions of Excel handle this request differently, Excel 2007 will insert the picture as an object, ie embed it in the workbook. Excel 2010 will insert it as a link, which is bad times if you plan on sending it to anyone. You need to change the insert to specify that it is embedded: Insert(Filename:= <path>, LinkToFile:= False, SaveWithDocument:= True)

这篇关于如何让图像出现在给定图像 url 的 Excel 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆