vba 从 Excel 中的 URL 加载图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13263019/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 18:23:15  来源:igfitidea点击:

Loading Image from URL in Excel

excelvba

提问by George KingoftheZombies Speach

Basically I have a gigantic excel spread sheet with over 20,000 URL's. It would be very inefficient of me to click on each link to check the image. Instead I was wondering if I could take the url from one cell and load the image into a different cell. This of course would have to be a loop as I have so many images to load. So far I found a thread on this already but I have no idea how to implement this code.

基本上我有一个巨大的 excel 电子表格,其中包含超过 20,000 个 URL。单击每个链接来检查图像对我来说效率非常低。相反,我想知道是否可以从一个单元格中获取 url 并将图像加载到另一个单元格中。这当然必须是一个循环,因为我有很多图像要加载。到目前为止,我已经找到了一个线程,但我不知道如何实现这段代码。

How to get images to appear in Excel given image url

如何让图像出现在给定图像 url 的 Excel 中

If someone could tell me how to use this code that would be great and you will also save my sanity. Thanks!

如果有人能告诉我如何使用这段代码,那就太好了,您也将挽救我的理智。谢谢!

回答by Ahmad

While your Excel sheet is open, press ALT+F11(Edit: Not Ctrl) This will open the Visual Basic editor. From there, locate the project explorer to the left side of the screen. It should appear something like VBAProject (YourWorkBookName.XLS)right click it and select Insert -> Module.

在 Excel 工作表打开时,按ALT+ F11(编辑:不是Ctrl)这将打开 Visual Basic 编辑器。从那里,找到屏幕左侧的项目资源管理器。它应该看起来像VBAProject (YourWorkBookName.XLS)右键单击它并选择插入 - >模块。

You should see a blank white space for you to put code in. Just paste the code you found from the other post, but make sure you paste it inside a SUB definition , like this:

您应该会看到一个空白区域供您放入代码。只需粘贴您从另一篇文章中找到的代码,但请确保将其粘贴到 SUB 定义中,如下所示:

Sub AnyNameCanBeChoosen()

   ' Paste your code Here

End Sub

Then press F5 to execute your code.

然后按 F5 执行您的代码。