可以使用VBA将图像(gif)从Web导入到Excel中吗? [英] Can I use VBA to import images (gifs) from the web into Excel?

查看:104
本文介绍了可以使用VBA将图像(gif)从Web导入到Excel中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Excel表格中的.gif文件的URL列表。我想使用VBA查询这些网站,并将这些图像插入相同的工作表。我使用Excel 2007。

I have a list of URLs to .gif files in an Excel sheet. I want to use VBA to query these websites and insert these images into the same worksheet. I am using Excel 2007.

我尝试使用获取外部数据 - 从Web功能查询网站,但返回以下错误:

I tried using the 'Get External Data - From Web' feature to query the website, but it returned the following error:

无法打开 http://.../blah .GIF 。Internet站点无法返回您请求的对象(HTTP / 1.0 403)

"Unable to open http://.../blah.GIF. The Internet site cannot return the object you request. (HTTP/1.0 403)"

这是因为Excel无法在线导入具有此功能的图像?或者这个问题与网站有关吗?

Is this because Excel cannot import online images with this feature? Or is this problem specifically related to the website?

最重要的是,还有其他一些方法可以在VBA中完成吗?

And most importantly, is there some other way to do this entirely in VBA?

推荐答案

是的,你可以这样做。其实很简单。 Excel有一个AddPicture函数。从Excel VBA帮助:

Yes, you can do so. It is actually quite easy. Excel has a AddPicture function. From Excel VBA Help:

表达式 AddPicture(Filename,LinkToFile,SaveWithDocument,Left,Top,Width,Height) strong>

expression.AddPicture(Filename, LinkToFile, SaveWithDocument, Left, Top, Width, Height)

使用如下:

Sheets(1).Shapes.AddPicture "http://www.mywebsite.com/images/map.gif" _
                          , msoFalse, msoTrue, 100, 100, 500, 600

左,顶,宽,身高都是必需的,而且分数。

Left, Top, Width, & Height are all required and in points.

这篇关于可以使用VBA将图像(gif)从Web导入到Excel中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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