在本例中,我的公式中有一张 grumpycat 图片的 URL.我也将此链接传递给我创建的名为 OnMouseOver 的函数将 DoOnce 变暗为布尔值公共函数 OnMouseOver(URL As String)如果不 DoOnce 那么DoOnce = 真使用 ActiveSheet.Pictures.Insert(URL)使用 .ShapeRange.LockAspectRatio = msoTrue.宽度 = 75. 高度 = 100结束于.Left = Cells(1, 2).Left.Top = Cells(1, 2).Top.放置= 1.PrintObject = 真结束于万一结束函数最后,为了在我们将鼠标悬停时清除它,我们必须在它附近的其他单元格中放置一些公式.=HYPERLINK(Reset())以及相关的函数:公共函数Reset()如果 DoOnce 那么DoOnce = 错误ActiveSheet.Pictures.Delete万一结束函数结果:编辑使用多个链接对此进行扩展.我们可以同时传递一个单元格引用,以使用多个链接执行此操作,并让它们出现在单元格旁边.将 DoOnce 变暗为布尔值公共函数 OnMouseOver(URL As String, TheCell As Range)重启如果不 DoOnce 那么DoOnce = 真使用 ActiveSheet.Pictures.Insert(URL)使用 .ShapeRange.LockAspectRatio = msoTrue.宽度 = 300. 高度 = 200结束于.Left = Cells(TheCell.Row, TheCell.Column + 1).Left.Top = Cells(TheCell.Row, TheCell.Column + 1).Top.放置= 1.PrintObject = 真结束于万一结束函数公共函数重置()如果 DoOnce 那么DoOnce = 错误ActiveSheet.Pictures.Delete万一结束函数I wanted to know is it possible to preview image links by hovering mouse cursor over image urls in excel, or google sheets, or any spreadsheet editor. 解决方案 You made me curious, so I looked into this.The answer is, yes - it requires a bit of VBA and is a bit hacky, but here's how you can do it.First of all, doing anything on cell hover in excel is a bit hacky.To do so, we use the HYPERLINK formula of a cell.=HYPERLINK(OnMouseOver("http://i.imgur.com/rQ5G8sZ.jpg"),"http://i.imgur.com/rQ5G8sZ.jpg")In this case, I have the URL of a grumpycat picture in my formula.I also pass this link to a function I create called OnMouseOverDim DoOnce As BooleanPublic Function OnMouseOver(URL As String)If Not DoOnce Then DoOnce = True With ActiveSheet.Pictures.Insert(URL) With .ShapeRange .LockAspectRatio = msoTrue .Width = 75 .Height = 100 End With .Left = Cells(1, 2).Left .Top = Cells(1, 2).Top .Placement = 1 .PrintObject = True End WithEnd IfEnd FunctionFinally, in order to clear it when we hover away, we have to put some formulas in the other cells near it.=HYPERLINK(Reset())And the associated function:Public Function Reset()If DoOnce Then DoOnce = False ActiveSheet.Pictures.DeleteEnd IfEnd FunctionResults:EditExpanding on this with multiple links.We can pass a cell reference along with this to do this with multiple links and have them appear next to the cell.Dim DoOnce As BooleanPublic Function OnMouseOver(URL As String, TheCell As Range)ResetIf Not DoOnce Then DoOnce = True With ActiveSheet.Pictures.Insert(URL) With .ShapeRange .LockAspectRatio = msoTrue .Width = 300 .Height = 200 End With .Left = Cells(TheCell.Row, TheCell.Column + 1).Left .Top = Cells(TheCell.Row, TheCell.Column + 1).Top .Placement = 1 .PrintObject = True End WithEnd IfEnd FunctionPublic Function Reset()If DoOnce Then DoOnce = False ActiveSheet.Pictures.DeleteEnd IfEnd Function 这篇关于将预览悬停在 excel 图像链接上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-29 20:34
查看更多