如何从批处理文件中打开一个Excel宏只有用户窗体 [英] How to Open only UserForm of an excel macro from batch file
问题描述
我试图通过批处理文件来打开一个Excel宏的UserForm1。我能打开,但练成也越来越与打开一起。我只想UserForm1被不打开Excel工作。下面是我的方法:
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 :
我已经写了一个宏来打开UserForm1
I have written a macros to open the UserForm1
Sub open_form()
UserForm1.Show
End Sub
在批处理文件:
@echo off
cd "c:\Test\"
openFormTest.xlsm
通过上面的方法,当我运行的批处理文件都UserForm1和Excel是越来越开放的,但我想只打开UserForm1。请帮我出
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.
试试这个
Sub open_form()
Application.Visible = False
UserForm1.Show vbModeless
End Sub
和无论是在一个按钮,你需要将其设置回为true,也可以使用 UserForm_QueryClose
事件
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
这篇关于如何从批处理文件中打开一个Excel宏只有用户窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!