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 opened not the excel. Below is my approach :
I have written a macros to open the UserForm1
Sub open_form()
UserForm1.Show
End Sub
In batch File:
@echo off
cd "c:\Test\"
openFormTest.xlsm
By the above approach, When I'm running the batch file both UserForm1 and excel are getting open, but I want to open only UserForm1. Kindly help me out
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With