我正在从一个工作簿(即wb1.xlsm)运行一个宏,它将模板工作簿复制到另一个位置并重命名它(即wb2.xlsm)。然后使用Application.Run运行位于wb2中的AutoSetup()Sub。这将根据给定的参数创建合适的工作表。
我的问题发生在这个过程中。它是使用UserForm中出现的现有函数设置的。
当我运行宏时,我不希望看到任何弹出,但即使Application.Events和Application.Visible设置为False执行设置计算的UserForm仍会弹出并可见。
有什么建议吗?
以下代码:
'AutoSetup Module
Public Sub AutoSetup(Project As String, Program As String, TestName As String, _
TestType As String, TaskNumber As String, Token As String)
Dim TokenArr() As String
Application.ScreenUpdating = False
Application.EnableEvents = False
Set IntSht = ActiveWorkbook.Sheets("Integrations")
Set DctSht = ActiveWorkbook.Sheets("Duct")
IntSht.Range("B4").value = Program
IntSht.Range("B5").value = TestName
IntSht.Range("E4").value = Project
IntSht.Range("E5").value = TaskNumber
Call WorkbookSetup
MenuForm.TestSetBox.value = TestType
TokenArr = Split(Base64DecodeString(Token), ",")
EPFLogin.TextBox1.value = TokenArr(0)
EPFLogin.TextBox2.value = TokenArr(1)
MenuForm.LoadSheets (True)
DctSht.Activate
ThisWorkbook.Save
ThisWorkbook.Close
End Sub
答案 0 :(得分:1)
Within wb2.xlsm
, move the calculations to a separate Sub
routine in a separate module. Call this Subroutine from 'AutoSetup' after showing the UserForm
.
Then from wb1.xlsm
, call the new subroutine.