我在代码的开头有这个声明。我在Outlook 2010 32位中通过功能区中的按钮运行宏。
Option Explicit
Private Map1(0 To 63) As Byte
Private Map2(0 To 127) As Byte
当用户第一次尝试运行宏时,Outlook崩溃:Microsoft Outlook已停止工作。解决方法是打开VBA编辑器并关闭。然后单击以运行宏并且它可以工作。当我删除这些声明时,不会发生此错误。
在开头运行的代码:
Option Explicit
Private InitDone As Boolean
Private Map1(0 To 63) As Byte
Private Map2(0 To 127) As Byte
Sub SDMC()
''' check if userform is already loaded '''
If SDMC_IsUserFormLoaded("ufSDMC") Then Unload ufSDMC
Load ufSDMC
Call ufSDMC.SdmcForm
End Sub
Function SDMC_IsUserFormLoaded(ByVal ufname As String) As Boolean
Dim uForm As Object
SDMC_IsUserFormLoaded = False
For Each uForm In VBA.UserForms
If uForm.Name = ufname Then
SDMC_IsUserFormLoaded = True
Exit For
End If
Next
End Function
还有一些函数使用这些变量,但是在宏启动时它们不会运行。