excel - 将预览悬停在 Excel 图像链接上

标签 excel vba google-sheets

我想知道是否可以通过将鼠标光标悬停在 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

结果: Results

编辑

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

我们可以传递一个单元格引用,以使用多个链接来执行此操作,并使它们出现在单元格旁边。

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

Results2

关于excel - 将预览悬停在 Excel 图像链接上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43923102/

相关文章:

excel - 如何将解析后的数据从一个单元格提取到另一个单元格

css - 当列中的日期是明天时,Google 表格电子邮件通知

c++ - 选定范围的Excel单元格传递给VBA函数的参数 “as Variant”,然后传递给c++中的ATL对象的方法

vba - 带可选参数的函数

google-sheets - 谷歌表格: FIlter/Query/Other to Omit "0" values from Rows AND Columns

excel - 使用单个标准的多个值

excel - 在 Excel 中使用 VBA 引用收件箱以外的 Outlook 邮箱

excel - 如何在 Excel 中使用 VBA 获取当前行并访问列?

c# - 如何在 excel csv 文件中添加两个表?

excel - Excel VBA中的解析列表?