java内嵌excel_如何在Excel中嵌入URL中的图像?

我试图从URL中提取图像并将其嵌入Excel中 .

我的Excel表格很简单:它包含2列 .

第1列具有图像URL . 在第2列中,我想嵌入图像 . 我使用以下代码 . 它在第一行工作得非常好,我在本地机器上保存了图像并给出了路径,但是当尝试直接从URL嵌入时它失败了 . 我收到以下错误:

Error - Run time 1004 , unable to get the insert property for the picture class.

我的代码:

Sub Button1_Click()

'ActiveSheet.Pictures.Insert("C:\810CfHBPGyL._SX425_.jpg").Select

'Updateby Extendoffice 20161116

Dim Pshp As Shape

Dim xRg As Range

Dim xCol As Long

'On Error Resume Next

Application.ScreenUpdating = False

Set Rng = ActiveSheet.Range("A2:A3")

MsgBox "Step1"

For Each cell In Rng

filenam = cell

MsgBox "Step2" & cell

ActiveSheet.Pictures.Insert(filenam).Select

MsgBox "Step3"

Set Pshp = Selection.ShapeRange.Item(1)

'MsgBox "Step4" & Pshp

If Pshp Is Nothing Then GoTo lab

xCol = cell.Column + 1

Set xRg = Cells(cell.Row, xCol)

With Pshp

.LockAspectRatio = msoFalse

.Width = 80

.Height = 80

.Top = xRg.Top + (xRg.Height - .Height) / 2

.Left = xRg.Left + (xRg.Width - .Width) / 2

End With

lab:

Set Pshp = Nothing

Range("A2").Select

Next

Application.ScreenUpdating = True

End Sub

这可能是Excel VBA引用的问题吗?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值