【问题标题】:Copy Excel range and paste to word from VB.Net app causes a 0x800A03EC error when used more than one从 VB.Net 应用程序复制 Excel 范围并粘贴到 word 使用多个时会导致 0x800A03EC 错误
【发布时间】:2021-06-18 03:39:07
【问题描述】:

在我的代码中,Copy Excel range and paste to word from 是正确完成的,但是当我为新的 range 应用重复此代码时,它会在多次使用时导致 0x800A03EC 错误。

Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
            My.Computer.FileSystem.WriteAllBytes(TempWord & "word", My.Resources._1, True)
            Dim sWORDFileName = TempWord & "word"
            Form1.oExcel.Range("B1:AM46").Copy()
            OWORD.DisplayAlerts = False
            OWORD.Documents.Open(sWORDFileName)
            OWORD.Selection.PasteSpecial(Link:=False, DataType:=9, Placement:=0, DisplayAsIcon:=False) 'Asked question to get this 
            OWORD.Selection.TypeParagraph()
            OWORD.Visible = True
            Form1.oExcel.Range("B49:AM93").Copy()
            OWORD.DisplayAlerts = False
            OWORD.Documents.Open(sWORDFileName)
            OWORD.Selection.PasteSpecial(Link:=False, DataType:=9, Placement:=0, DisplayAsIcon:=False) 'Asked question to get this 
            OWORD.Selection.TypeParagraph()
            OWORD.Visible = True
End Sub

【问题讨论】:

    标签: excel vb.net ms-word


    【解决方案1】:

    根据错误号,Office 应用程序在服务器端是自动化的,下面是 MS 的说明:

    Microsoft 目前不推荐也不支持任何无人值守、非交互式客户端应用程序或组件(包括 ASP、ASP.NET、DCOM 和 NT 服务)的 Microsoft Office 应用程序自动化,因为 Office 可能表现出不稳定Office 在此环境中运行时的行为和/或死锁。

    如果您要构建在服务器端上下文中运行的解决方案,您应该尝试使用已确保无人值守执行安全的组件。或者,您应该尝试找到允许至少部分代码在客户端运行的替代方案。如果您使用服务器端解决方案中的 Office 应用程序,该应用程序将缺少许多成功运行所需的功能。此外,您将在整体解决方案的稳定性方面承担风险。

    Considerations for server-side Automation of Office 文章中了解更多信息。

    如果您只处理开放的 XML 文档,作为一种可能的解决方法,您可以考虑使用 Open XML SDK,请参阅Welcome to the Open XML SDK 2.5 for Office 了解更多信息。此外,您可能会发现为服务器端执行而设计的第三方组件很有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-15
      • 1970-01-01
      • 2017-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多