4,009
社区成员




Option Explicit
Sub Window_OnLoad
on error resume next
Dim m_Excel
Dim m_FSO
Const m_FILENAME = "要删除的文件.xls"
Set m_FSO = CreateObject("Scripting.FileSystemObject")
Set m_Excel = CreateObject("Excel.Application")
With m_Excel
.Workbooks.Open(m_FILENAME)
.Visible = True
.DisplayAlerts=False
.WindowState = -4137 'xlMaximized
.ActiveWindow.WindowState = -4137 'xlMaximized
.CommandBars("Worksheet Menu Bar").Enabled = True
End With
' 等待EXCEL结束
Dim m_WindowCount
m_WindowCount = m_Excel.Workbooks.count
Do Until m_WindowCount = 0
Sleep 2000 '此处未执行...
m_WindowCount = m_Excel.Workbooks.Count
Loop
' 结束进程
Set m_Excel = Nothing
' 删除文件
if m_FSO.FileExists(m_FILENAME) = True Then
m_FSO.DeleteFile m_FILENAME
End if
' 关闭HTA
Set m_FSO = Nothing
Self.Close
End Sub
<!doctype html public "-//W3C//DTD HTML 4.0//EN">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<script type="text/vbscript" language="vbscript">
Option Explicit
Dim m_Excel
Dim m_FSO
Dim tid
Const m_FILENAME = "d:\xx.xls"
tid = Null
Sub check
If Not IsNull(tid) Then
window.clearTimeout tid
tid = Null
End If
Dim m_WindowCount
m_WindowCount = m_Excel.Workbooks.count
If m_WindowCount = 0 Then
' 结束进程
Set m_Excel = Nothing
' 删除文件
if m_FSO.FileExists(m_FILENAME) = True Then
m_FSO.DeleteFile m_FILENAME
End if
' 关闭HTA
Set m_FSO = Nothing
Self.Close
Else
tid = window.setTimeout("check", 2000)
End If
End Sub
Sub Window_OnLoad
'on error resume next
Set m_FSO = CreateObject("Scripting.FileSystemObject")
Set m_Excel = CreateObject("Excel.Application")
With m_Excel
.Workbooks.Open(m_FILENAME)
.Visible = True
.DisplayAlerts=False
.WindowState = -4137 'xlMaximized
.ActiveWindow.WindowState = -4137 'xlMaximized
.CommandBars("Worksheet Menu Bar").Enabled = True
End With
tid = window.setTimeout("check", 2000)
End Sub
</script>
</head>
<body bgcolor="#eeeeee">
<center>
<br>
<a>请等待...</a>
</center>
</body>
</html>
<!doctype html public "-//W3C//DTD HTML 4.0//EN">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
<script type="text/vbscript" language="vbscript">
Option Explicit
Sub Window_OnLoad
on error resume next
Dim m_Excel
Dim m_FSO
Const m_FILENAME = "要删除的文件.xls"
Set m_FSO = CreateObject("Scripting.FileSystemObject")
Set m_Excel = CreateObject("Excel.Application")
With m_Excel
.Workbooks.Open(m_FILENAME)
.Visible = True
.DisplayAlerts=False
.WindowState = -4137 'xlMaximized
.ActiveWindow.WindowState = -4137 'xlMaximized
.CommandBars("Worksheet Menu Bar").Enabled = True
End With
' 等待EXCEL结束
Dim m_WindowCount
m_WindowCount = m_Excel.Workbooks.count
Do Until m_WindowCount = 0
Sleep 2000 '此处未执行...
m_WindowCount = m_Excel.Workbooks.Count
Loop
' 结束进程
Set m_Excel = Nothing
' 删除文件
if m_FSO.FileExists(m_FILENAME) = True Then
m_FSO.DeleteFile m_FILENAME
End if
' 关闭HTA
Set m_FSO = Nothing
Self.Close
End Sub
</script>
</head>
<body bgcolor="#eeeeee">
<center>
<br>
<a>请等待...</a>
</center>
</body>
</html>