我想打开一个对话框,告诉用户等到Excel文件和程序加载完毕。
如何在VBS中显示对话框?
我用过的VBScript:
Option Explicit
Dim objExcel, objWorkBook
//start dialog here?
Set objExcel = CreateObject("excel.application")
objExcel.Visible = false
Set objWorkBook = objExcel.Workbooks.Open("C:\Tester.xlsm")
objExcel.Run "Tester.xlsm!modul1.subTest"
objWorkBook.Close True
objExcel.Quit
Set objWorkBook = Nothing
Set objExcel = Nothing
答案 0 :(得分:0)
借用Scripting Guy Blog中的一些代码,您可以使用HTA作为启动/加载屏幕,并在打开工作簿后将其移出屏幕:
<html>
<head>
<title>Splash Screen</title>
<HTA:APPLICATION
APPLICATIONNAME="Splash Screen"
SCROLL="no"
SINGLEINSTANCE="yes"
WINDOWSTATE="normal"
BORDER="none"
INNERBORDER="no"
SHOWINTASKBAR="no"
>
</head>
<script language="VBScript">
Dim xl, wb
Sub Window_OnLoad
Set xl = CreateObject("Excel.Application")
Set wb = xl.Workbooks.Open("C:\Tester.xlsm")
screenWidth = document.parentWindow.screen.availWidth
screenHeight = document.parentWindow.screen.availHeight
window.moveTo -(screenWidth + 50), -(screenHeight + 50)
xl.Run "Tester.xlsm!modul1.subTest"
wb.Close True
xl.Quit
self.close
End Sub
</script>
<body>
<p>Loading Excel. Please wait.</p>
</body>
</html>