我正在从excel构建word文档。当我在文档中插入图像并重新调整大小时,我得到一个运行时错误。我只是在第二次运行它时才发生。
Dim PreparedSigPath As String
Dim sWdth, sHght As Single
'file paths for image
PreparedSigPath = Range("Prepared_Sig").Value
'insert and re-size image
Set PreparedSig = docreport.Bookmarks("PREPARED_SIG").Range.InlineShapes _
.AddPicture(PreparedSigPath)
With PreparedSig
sWdth = .Width
sHght = .Height
'size to max width
.Width = InchesToPoints(2.125)
.Height = sHght * .Width / sWdth
'size to max height if needed
If .Height > InchesToPoints(0.625) Then
.Height = InchesToPoints(0.625)
.Width = sWdth * .Height / sHght
End If
End With
代码在.Width = InchesToPoints(2.125)
答案 0 :(得分:0)
尝试使用
.Width = Application.InchesToPoints(2.125)
。