我已经建立了一个模板,帮助用户插入图像。
在VBA中,我使用了Pictures.insert,,但是后来我发现这个方法默认情况下偷偷地插入到图像的链接,而不是嵌入它。显然,这意味着它不能被第三方看谁没有连接到我们的网络。
所以,虽然我现在已经修复了模板,但是在各种文件夹中有几百个文件已经被设置并填充了链接的图像。
我认为我需要的是一个VBA脚本,它将遍历所选文件夹系统中每个可见工作簿中的每个工作表,并将所有链接的图像“转换”为embedded (nb )。有些图像是手动插入的,因此没有链接)
我咨询过我的IT联系人,并在这里和其他地方在线搜索,但我找不到解决方案。
请问有人有什么想法吗?
简单的样品附呈。保存在Google上的ImageLink Excel文档
这是我用来插入图像的代码,如果有任何帮助的话。生成URL的逻辑在电子表格中处理:
Sub InsertImage()
' This script inserts the image file referenced by the active cell
' Via https://www.extendoffice.com/documents/excel/4212-excel-insert-image-from-url.html
Dim Rng As Range
Dim filenam As String
On Error Resume Next
Application.ScreenUpdating = False
Set Rng = Selection
Sheets("Sheet1").Range("activefile").Value = Rng.Value
filenam = Range("filenurl").Value
ActiveSheet.Pictures.Insert(filenam).Select
End Sub发布于 2018-07-18 17:46:23
您可以复制图像并将其替换为粘贴的副本:
Sub Macro1()
Unlink ActiveSheet.Shapes(1)
End Sub
Sub Unlink(s)
Dim t, l, h, w, ws
With s
Set ws = .DrawingObject.Parent
t = .Top
l = .Left
h = .Height
w = .Width
.Copy
'might need to adjust the paste format...
ws.PasteSpecial Format:="Picture (PNG)", _
Link:=False, DisplayAsIcon:=False
End With
With ws.Shapes(ws.Shapes.Count)
.Top = t
.Left = l
.Height = h
.Width = w
End With
End Subhttps://stackoverflow.com/questions/51406551
复制相似问题