保持模块上的全局变量值

保持模块上的全局变量值

再会

我确实在脚本中创建了一个全局变量。它确实正确地将变量本身保存在模块中,但它没有保存变量的内容。有没有办法保留它的包含内容?

我尝试过

Set ProcessFileName = ActiveWorkbook.Name

但是此行返回一个错误。

我确实尝试了 Global 和 Public。

我的代码:

Option Explicit
Global FirstDay As Boolean
Global ProdPreviousFileName  As String
Global WMsgBox As Integer
Global PreviousDate As String
Global PreviousFile As String
Public ProcessFileName As String

Sub Auto_Open()

 ProcessFileName = ActiveWorkbook.Name 'This is the Variable I want to keep the contain
    
Sheets("GENERAL INFORMATION").Select
Range("A1").Select


WMsgBox = MsgBox("Start Compliancy Report Building ?", vbQuestion + vbYesNo)

If WMsgBox = vbYes Then
    WMsgBox = MsgBox("Is is the first business day of the week ?", vbQuestion + vbYesNo)
    If WMsgBox = vbYes Then
        FirstDay = True
        PreviousFile = Application.GetOpenFilename( _
        Title:="Select previous available Compliancy Report")
    Call Module1.DEFINE_PROD_VARIABLES

    Else
    FirstDay = False
        PreviousFile = Application.GetOpenFilename( _
        Title:="Select previous available Compliancy Report")
    Call Module1.DEFINE_PROD_VARIABLES
    End If
Else
End If
End Sub

相关内容