Excel 将对象传递给子例程时没有响应

Excel Not Responding When Passing Objects To Subroutine

这个宏在我们的大部分工作计算机上运行良好,但不是我们所有的工作计算机。每个人都是 运行 Excel 2013 年和具有大量 RAM (4-8 GB) 的较新计算机。

这是正在调用的子例程:

Public Sub EmailApprovalP1(GeneralSection As Object, ItemSection As
   Object, VendorSection As Object, MarketSection As Object, Part1Section
   As Object, wbLog As Workbook, wbPCD As Workbook, resubmission As Boolean)

并且,这是对该子例程的调用:

Call EmailApprovalP1(GeneralSection, ItemSection, VendorSection, 
   MarketSection, Part1Section, wbLog, wbPCD, resubmission)

当 VBA 代码读取上面的 Call 时,Excel 开始不响应,要么恢复,要么在某些情况下完全关闭 :(.

我在这里搜索了其他问题和答案,但找不到与我的经历相似的内容。

任何有关如何解决此问题的想法或有关如何解决此问题的建议都将不胜感激。

通过在子例程的参数中明确说明 'ByRef',我能够使它在有问题的计算机上运行。

Public Sub EmailApprovalP1(ByRef GeneralSection As Object, ByRef 
   ItemSection As Object, ByRef VendorSection As Object, ByRef 
   MarketSection As Object, ByRef Part1Section As Object, ByRef wbLog As 
   Workbook, ByRef wbPCD As Workbook, ByRef resubmission As Boolean)

我非常惊讶这解决了这个问题,因为如果省略 'ByRef' 是隐含的。