双击一个单元格以显示VBA中excel链接中的图片 [英] Double click a cell to show a picture from a link in excel with VBA

查看:49
本文介绍了双击一个单元格以显示VBA中excel链接中的图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下功能,如果将鼠标放在图片上,它将显示图片.它非常整洁,效果很好.但是,我希望将其从将鼠标移到其上来更改为双击功能.

I have the following function that will display a picture if you run your mouse over it. It's quite neat and works well. However, I'd like to change it from running your mouse over it to a double click function.

下面是可运行的代码,当您在单元格上运行鼠标时,该代码将显示图片:

Below is the code that works that will show a picture when you run a mouse over a cell:

Dim DoOnce As Boolean
Public Function OnMouseOver(URL As String, TheCell As Range)

DoOnce = True
    With ActiveSheet.Pictures.Insert(URL)
        With .ShapeRange
            .LockAspectRatio = msoTrue
            .Width = 570
            .Height = 380
        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 Function

我知道我需要以下代码,如果您双击它,将会发生某些事情:

And I know I need the below code, of sorts, that if you double click on it something will happen:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    If Target.Address = "$A$1" Then
        'do something
    End If
    Cancel = True
End Sub

我似乎无法将两者合并-以便获得原始代码的功能,但是需要双击而不是仅将鼠标移到单元格上.

I just can't seem to merge the two - so that I get the functionality of the original code, but with needing a double click rather than just passing the mouse over the cell.

初始代码以顺序的顺序引用我计算机上图片的串联图片查找地址.随着生成更多图片,我将复制带有公式的新链接,这是快速,简单和容易的,这就是为什么我要保留初始代码的"OnMouseOver"功能,因此可以轻松地将其复制到新单元格中.我只想采取行动将图片显示为双击,而不是将鼠标置于当前工作的单元格上方.

The initial code references a concatenated picture lookup address in for pictures on my computer in sequential order for a process. I copy new links with the formula as more pictures are generated, which is quick, simple, and easy, and is why I want to keep the "OnMouseOver" function of the initial code, so I can copy this easily to new cells. I just want to action to reveal the pictures to be a double click, and not running the mouse over the cells as it currently works.

如果我能帮上忙的话,那将是一个很大的帮助.

It would be a big help if I could get a hand with this.

谢谢

史蒂夫

推荐答案

此问题的答案可以在下面的链接中找到.

Answer to this question can be found at the link below.

https://www.mrexcel.com/board/threads/double-click-a-cell-to-show-a-picture-from-a-link.1136465/page-2

这篇关于双击一个单元格以显示VBA中excel链接中的图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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