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

时间:2015-01-28 14:33:11

标签: excel vba excel-vba 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代码读取上面的调用时,Excel开始没有响应,要么恢复,要么在某些情况下完全关闭:(。

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

关于如何解决此问题的任何想法或有关如何解决此问题的建议将非常感激。

1 个答案:

答案 0 :(得分:0)

我能够通过在子例程的参数中明确声明“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'是隐含的。