在此处输入代码我想为每个插入的图像创建一个超链接。在此示例中,列A代表色样的名称,而列B具有实际图像。
示例
A栏1001
B列图像已插入
我希望我的预期结果在下面的屏幕截图中看起来像这样。超链接将显示在列C上。当用户单击超链接时,它将基于颜色名称打开图像。使用VBA可以做到这一点吗?
A列1001 插入了B列图像 C栏1001.jpg
答案 0 :(得分:0)
尝试一下:
Sub insertlink()
' insertlink Macro
ActiveSheet.Shapes.Range(Array("Picture 2")).Select
arr = Selection.ShapeRange.Item(1).Hyperlink.Address
''the cell you want the formula in needs to be selected. it is set to put
''the value of the cell two to columns left of it as the value.
ActiveCell.FormulaR1C1 = "=RC[-2]"
ActiveCell.Select ''use activeCell to make this relative.''
Selection.Hyperlinks.Add Anchor:=Selection, Address:=arr
End Sub