How to Open only UserForm of an excel macro from batch file

后端 未结 3 1166
被撕碎了的回忆
被撕碎了的回忆 2020-12-06 19:50

I\'m trying to open the UserForm1 of an excel macro through batch file. I\'m able to open that but excel is also getting opened along with that. I want only UserForm1 to be

3条回答
  •  -上瘾入骨i
    2020-12-06 20:18

    You need to show the UserForm in modeless mode and then hide the application.

    try this

    Sub open_form()
        Application.Visible = False
        UserForm1.Show vbModeless
    End Sub
    

    and either in a button you need to set it back to true or you can use the UserForm_QueryClose event

    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
        Application.Visible = True
        ThisWorkbook.Close SaveChanges:=False
    End Sub
    

提交回复
热议问题