我在选择单元格上添加图像,图像在单元格上完美添加,但是当我将该表格转换为html时,图像会中断 这是我用于在单元格上添加图像的代码
Public Function SetImage(tag As String)
'tag is the selected image path
On Error GoTo ErrHandler:
Dim shp, rng As Range
Set rng = Range(Selection.Address)
Set shp = ActiveSheet.Pictures.Insert(tag)
With shp
.Top = rng.Top
.Left = rng.Left
.ShapeRange.LockAspectRatio = msoTrue
.Width = .Width / Application.Max(.Width / rng.Width, _
.Height / rng.Height)
Visible = True
End With
Exit Function
ErrHandler:
ShowErrorInfo ("SetTag")
End Function
以下是此功能的结果
但转换后的图片在网页中显示为
Excel会像这样转换图像。 我正在使用mocrosft互操作库将Excel工作表转换为网页
答案 0 :(得分:0)
找到解决方案: 添加图片作为形状已经解决了问题
Set rng = Range(Selection.Address)
ActiveSheet.Shapes.AddPicture Filename:=tag, linktofile:=msoFalse, _
savewithdocument:=msoCTrue, Left:=rng.Left, Top:=rng.Top, Width:=rng.Width, Height:=rng.Height