【问题标题】:Run-time error '462' - Excel automation fails second time code runs运行时错误“462” - Excel 自动化第二次代码运行失败
【发布时间】:2015-12-08 01:54:29
【问题描述】:

我正在从 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)中断

【问题讨论】:

    标签: excel vba ms-word runtime-error


    【解决方案1】:

    尝试使用

    .Width = Application.InchesToPoints(2.125).

    【讨论】:

      猜你喜欢
      • 2017-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-01
      • 1970-01-01
      • 2011-09-02
      • 2015-06-23
      • 2023-03-06
      相关资源
      最近更新 更多