我想知道是否可以通过将鼠标光标悬停在 Excel、Google 表格或任何电子表格编辑器中的图像网址上来预览图像链接。
最佳答案
你让我很好奇,所以我对此进行了调查。
答案是肯定的 - 它需要一点 VBA,而且有点麻烦,但您可以按照以下方法实现。
首先,在 Excel 中对单元格悬停执行任何操作都有点麻烦。
为此,我们使用单元格的HYPERLINK
公式。
=HYPERLINK(OnMouseOver("http://i.imgur.com/rQ5G8sZ.jpg"),"http://i.imgur.com/rQ5G8sZ.jpg")
在本例中,我的公式中有一张脾气暴躁的猫图片的 URL。
我还将此链接传递给我创建的名为 OnMouseOver
Dim DoOnce As Boolean
Public 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 With
End If
End Function
最后,为了在我们将鼠标悬停时清除它,我们必须在它附近的其他单元格中放置一些公式。
=HYPERLINK(重置())
以及相关函数:
Public Function Reset()
If DoOnce Then
DoOnce = False
ActiveSheet.Pictures.Delete
End If
End Function
编辑
通过多个链接对此进行扩展。
我们可以传递一个单元格引用,以使用多个链接来执行此操作,并使它们出现在单元格旁边。
Dim DoOnce As Boolean
Public Function OnMouseOver(URL As String, TheCell As Range)
Reset
If 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 With
End If
End Function
Public Function Reset()
If DoOnce Then
DoOnce = False
ActiveSheet.Pictures.Delete
End If
End Function
关于excel - 将预览悬停在 Excel 图像链接上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43923102/