简体   繁体   English

Excel VBA:从另一个工作表的URL显示图像

[英]Excel VBA: Display Image from URL from another Sheet

need some help. 需要一些帮助。

I have been searching around after a code in excel that would let me display and URL as an image. 我一直在搜索excel中的代码,它可以让我显示和URL作为图像。 I have found a few good tips and codes but i'm not able to get it how i want. 我找到了一些很好的提示和代码,但我无法得到它我想要的。

The Image URL is located in Sheet1 B15 and i what do show the image in a merged cell in Sheet2 B/C-22 to 36. Don't know if it is possible to display it inside the merged cell. 图像URL位于Sheet1 B15中,我在Sheet2 B / C-22到36的合并单元格中显示图像。不知道是否可以在合并的单元格中显示它。

The reason for this is that i need to change the image URL and also Sheet2 is going to be sent as an html email. 原因是我需要更改图像URL,并且Sheet2将作为html电子邮件发送。

Thanks for any help i can get! 感谢您的帮助!

You can use vba to insert a picture into a range 您可以使用vba将图片插入范围

    Sub Button1_Click()
    Dim myTng As Range, myPict As Picture

    Set myRng = Range("B22:C36")
    Set myPict = myRng.Parent.Pictures.Insert(Sheets("Sheet1").Range("B15").Value)

    myPict.ShapeRange.LockAspectRatio = msoFalse
    myPict.Top = myRng.Top
    myPict.Width = myRng.Width
    myPict.Height = myRng.Height
    myPict.Left = myRng.Left
    myPict.Placement = xlMoveAndSize

End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM