将鼠标悬停在Excel图像链接上 [英] Hover preview over excel image link

查看:129
本文介绍了将鼠标悬停在Excel图像链接上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可以通过将鼠标光标悬停在excel,google表格或任何电子表格编辑器中的图像网址上来预览图像链接.

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.

答案是,是的-它需要一些VBA并且有点黑,但这是您可以做到的方式.

The answer is, yes - it requires a bit of VBA and is a bit hacky, but here's how you can do it.

首先,在excel中的单元格悬停上执行任何操作都是有点棘手.

First of all, doing anything on cell hover in excel is a bit hacky.

为此,我们使用单元格的HYPERLINK公式.

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.

我还将这个链接传递给我创建的名为OnMouseOver

I also pass this link to a function I create called 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

最后,为了在悬停时清除它,我们必须在附近的其他单元格中添加一些公式.

Finally, in order to clear it when we hover away, we have to put some formulas in the other cells near it.

=HYPERLINK(Reset())

及相关功能:

Public Function Reset()
If DoOnce Then
    DoOnce = False
    ActiveSheet.Pictures.Delete
End If
End Function

结果:

修改

通过多个链接对此进行扩展.

Expanding 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 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图像链接上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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