Excel 2016-Application.visible = true-生成Excel的新实例

时间:2018-08-23 10:36:29

标签: excel vba

我有一个隐藏应用程序的用户窗体。但是,当我关闭用户窗体并设置application,visible = true时,该应用程序变为可见,但是创建了两个无法关闭的excel新实例,除了通过杀死任务之外。在旧版本的excel上,此代码可以完美运行。

希望有人可以提供帮助。 :)

Private Sub UserForm_Activate()
Dim rs As Worksheet
Dim rngWA As Range


    Set rs = Worksheets("VenDetail")
    Set rngWA = rs.Range("B2:B" & rs.Cells(Rows.count, "B").End(xlUp).Row + 2)

    With Me.ListBox1
        .ColumnCount = 1
        .ColumnWidths = "300"
        .RowSource = "VenDetail!" & rngWA.Address
    End With

    Application.Visible = False

End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    Application.Visible = True
    Unload Me

End Sub

0 个答案:

没有答案